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

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/466620563bdbb31858e82462cdc0ae62605c9206

---
 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 5d3e0f9771c..39533266aeb 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -739,8 +739,15 @@ static int samldb_schema_add_handle_linkid(struct samldb_ctx *ac)
 	schema = dsdb_get_schema(ldb, ac);
 	schema_dn = ldb_get_schema_basedn(ldb);
 
-	el = dsdb_get_single_valued_attr(ac->msg, "linkID",
-					 ac->req->operation);
+	ret = dsdb_get_expected_new_values(ac,
+					   ac->msg,
+					   "linkID",
+					   &el,
+					   ac->req->operation);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+
 	if (el == NULL) {
 		return LDB_SUCCESS;
 	}
-- 
2.23.0

