From 2991eedefc19367b57313b72a3b741eae74d049c Mon Sep 17 00:00:00 2001
From: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Date: Wed, 20 Oct 2021 17:15:00 +1300
Subject: [PATCH 163/266] CVE-2020-25722 s4/dsdb/samldb:
 samldb_user_account_control_change() checks all values

There is another call to dsdb_get_expected_new_values() in this function
that we change in the next commit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14876

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Conflict:NA
Reference:https://gitlab.com/samba-team/samba/-/commit/2991eedefc19367b57313b72a3b741eae74d049c

---
 source4/dsdb/samdb/ldb_modules/samldb.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index ba56cf8826e..b84ef4c26d5 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -2807,8 +2807,15 @@ static int samldb_user_account_control_change(struct samldb_ctx *ac)
 	bool old_is_critical = false;
 	bool new_is_critical = false;
 
-	el = dsdb_get_single_valued_attr(ac->msg, "userAccountControl",
-					 ac->req->operation);
+	ret = dsdb_get_expected_new_values(ac,
+					   ac->msg,
+					   "userAccountControl",
+					   &el,
+					   ac->req->operation);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+
 	if (el == NULL || el->num_values == 0) {
 		ldb_asprintf_errstring(ldb,
 			"%08X: samldb: 'userAccountControl' can't be deleted!",
-- 
2.23.0

