From: kshumikhina Date: Wed, 3 Jun 2026 21:50:52 +0000 (+0400) Subject: s3: fix NULL pointer dereference in tcopy_passwd via pw_gecos X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=98bc8661ef4f4fdfbd9a2bcde6ff31d3bdf3b35f;p=thirdparty%2Fsamba.git s3: fix NULL pointer dereference in tcopy_passwd via pw_gecos If gecos, displayName, and cn attributes are all missing from the LDAP entry, unix_pw.pw_gecos remains NULL. This causes a crash inside tcopy_passwd due to a NULL pointer dereference. Fix this by falling back to an empty string, matching the behavior of pw_dir and pw_shell. Pair-Programmed-With: Dmitry Mikhalchenko Signed-off-by: Shumikhina Ksenia Reviewed-by: Volker Lendecke Reviewed-by: Anoop C S Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri Jun 12 15:22:01 UTC 2026 on atb-devel-224 --- diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 1d9fb80b3e2..4364ebbb12a 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1033,6 +1033,9 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state, if (unix_pw.pw_gecos == NULL) { unix_pw.pw_gecos = fullname; } + if (unix_pw.pw_gecos == NULL) { + unix_pw.pw_gecos = discard_const_p(char, ""); + } unix_pw.pw_dir = smbldap_talloc_single_attribute( priv2ld(ldap_state), entry,