]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: fix NULL pointer dereference in tcopy_passwd via pw_gecos gitlab/master
authorkshumikhina <ksen.shum@gmail.com>
Wed, 3 Jun 2026 21:50:52 +0000 (01:50 +0400)
committerVolker Lendecke <vl@samba.org>
Fri, 12 Jun 2026 15:22:01 +0000 (15:22 +0000)
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 <tascad@altlinux.org>
Signed-off-by: Shumikhina Ksenia <shumikhinaka@sgu.ru>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Jun 12 15:22:01 UTC 2026 on atb-devel-224

source3/passdb/pdb_ldap.c

index 1d9fb80b3e2d0e3f68b920f6d2313ee8655b8d1f..4364ebbb12a9aa974c4c8bac4ac0d129ee3ad1b5 100644 (file)
@@ -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,