From: Daniil Sarafannikov Date: Thu, 11 Jun 2026 14:58:37 +0000 (+0400) Subject: s4:dsdb: check if domain is not empty X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85d6edbd814fd01c3168402060b3a12cdec159f8;p=thirdparty%2Fsamba.git s4:dsdb: check if domain is not empty domain[strlen(domain)-1] leads to UB if strlen(domain) == 0, so we add check that domain is not empty before accessing the last symbol. Pair-Programmed-With: Dmitriy Mikhalchenko Signed-off-by: Daniil Sarafannikov Reviewed-by: Anoop C S Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri Jun 12 11:41:01 UTC 2026 on atb-devel-224 --- diff --git a/source4/dsdb/samdb/ldb_modules/netlogon.c b/source4/dsdb/samdb/ldb_modules/netlogon.c index 479b3a6deec..c3d417e1cad 100644 --- a/source4/dsdb/samdb/ldb_modules/netlogon.c +++ b/source4/dsdb/samdb/ldb_modules/netlogon.c @@ -81,7 +81,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx, NTSTATUS status; /* the domain parameter could have an optional trailing "." */ - if (domain && domain[strlen(domain)-1] == '.') { + if (domain && domain[0] != '\0' && domain[strlen(domain)-1] == '.') { domain = talloc_strndup(mem_ctx, domain, strlen(domain)-1); NT_STATUS_HAVE_NO_MEMORY(domain); }