[openssh-commits] [openssh] branch master updated: ensure struct passwd fields are non-NULL in pwcopy
git+noreply at mindrot.org
git+noreply at mindrot.org
Tue Sep 30 09:49:49 AEST 2025
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
The following commit(s) were added to refs/heads/master by this push:
new d343df401 ensure struct passwd fields are non-NULL in pwcopy
d343df401 is described below
commit d343df4019b4369ce7f87e9bf6bbc80b81cd263d
Author: zhangjun <zhangjun-tc at dfmc.com.cn>
AuthorDate: Fri Aug 22 16:49:07 2025 +0800
ensure struct passwd fields are non-NULL in pwcopy
Android libc can return NULL pw_gecos, for example.
---
misc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/misc.c b/misc.c
index 239ed1238..ce77ec943 100644
--- a/misc.c
+++ b/misc.c
@@ -506,7 +506,7 @@ pwcopy(struct passwd *pw)
copy->pw_name = xstrdup(pw->pw_name);
copy->pw_passwd = xstrdup(pw->pw_passwd == NULL ? "*" : pw->pw_passwd);
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
- copy->pw_gecos = xstrdup(pw->pw_gecos);
+ copy->pw_gecos = xstrdup(pw->pw_gecos == NULL ? "" : pw->pw_gecos);
#endif
copy->pw_uid = pw->pw_uid;
copy->pw_gid = pw->pw_gid;
@@ -517,10 +517,10 @@ pwcopy(struct passwd *pw)
copy->pw_change = pw->pw_change;
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
- copy->pw_class = xstrdup(pw->pw_class);
+ copy->pw_class = xstrdup(pw->pw_class == NULL ? "" : pw->pw_class);
#endif
- copy->pw_dir = xstrdup(pw->pw_dir);
- copy->pw_shell = xstrdup(pw->pw_shell);
+ copy->pw_dir = xstrdup(pw->pw_dir == NULL ? "" : pw->pw_dir);
+ copy->pw_shell = xstrdup(pw->pw_shell == NULL ? "" : pw->pw_shell);
return copy;
}
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list