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
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,