From ca2f4e0b4c60856a1267912e5398f8a74e74dd4a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 12 Oct 2016 12:35:12 +0200 Subject: [PATCH] lib: Fix CID 1373623 Dereference after null check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should not overload "p", this is used in the outer loop BUG: https://bugzilla.samba.org/show_bug.cgi?id=12276 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Böhme Reviewed-by: Jeremy Allison (cherry picked from commit 6ec81ca3c196f3c4659a4e1c473759b393708d12) --- source3/lib/substitute.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 1f98327..f56e2c4 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -524,9 +524,10 @@ char *talloc_sub_basic(TALLOC_CTX *mem_ctx, group_name = gidtoname(pass->pw_gid); if (is_domain_name) { - p = strchr_m(group_name, *sep); - if (p != NULL) { - group_name = p + 1; + char *group_sep; + group_sep = strchr_m(group_name, *sep); + if (group_sep != NULL) { + group_name = group_sep + 1; } } a_string = realloc_string_sub(a_string, -- 2.9.3