From: Volker Lendecke Date: Sat, 30 Aug 2025 12:01:59 +0000 (+0200) Subject: dsdb: Fix CID 1665142, Null pointer dereferences (FORWARD_NULL) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dede5475d3da31af89394c71b3ade706da7358a9;p=thirdparty%2Fsamba.git dsdb: Fix CID 1665142, Null pointer dereferences (FORWARD_NULL) Do the ADD/MOD early, don't risk dereferencing msg without assignment. Signed-off-by: Volker Lendecke Reviewed-by: Martin Schwenke --- diff --git a/source4/dsdb/samdb/ldb_modules/acl.c b/source4/dsdb/samdb/ldb_modules/acl.c index 8432dbfe25b..62f1f01f59b 100644 --- a/source4/dsdb/samdb/ldb_modules/acl.c +++ b/source4/dsdb/samdb/ldb_modules/acl.c @@ -874,10 +874,16 @@ static int acl_check_dns_host_name(TALLOC_CTX *mem_ctx, return ldb_oom(ldb); } - if (req->operation == LDB_MODIFY) { + switch (req->operation) { + case LDB_MODIFY: msg = req->op.mod.message; - } else if (req->operation == LDB_ADD) { + break; + case LDB_ADD: msg = req->op.add.message; + break; + default: + talloc_free(tmp_ctx); + return LDB_ERR_OPERATIONS_ERROR; } if (implicit_validated_write_control != NULL) { @@ -958,11 +964,8 @@ static int acl_check_dns_host_name(TALLOC_CTX *mem_ctx, } search_res = acl_res->msgs[0]; - } else if (req->operation == LDB_ADD) { - search_res = msg; } else { - talloc_free(tmp_ctx); - return LDB_ERR_OPERATIONS_ERROR; + search_res = msg; } /* Check if the account has objectclass 'computer' or 'server'. */