diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-06-02 07:16:10 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-06-02 07:16:10 +0000 |
commit | eff96b52edf00b5721cd2c3b90d509f4653dd1be (patch) | |
tree | 6500a4b22d4836304ac356ac48541a8e24df8018 | |
parent | 20ce7b12268a3d32b5b246928de5084322e709cf (diff) | |
download | perl-eff96b52edf00b5721cd2c3b90d509f4653dd1be.tar.gz |
avoid dereferencing null pointer from getpwent() et al
p4raw-id: //depot/perl@3519
-rw-r--r-- | pp_sys.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -4556,7 +4556,7 @@ PP(pp_gpwent) struct passwd *pwent; STRLEN n_a; #ifdef HAS_GETSPENT - struct spwd *spwent; + struct spwd *spwent = NULL; #endif if (which == OP_GPWNAM) @@ -4567,14 +4567,18 @@ PP(pp_gpwent) pwent = (struct passwd *)getpwent(); #ifdef HAS_GETSPNAM - if (which == OP_GPWNAM) - spwent = getspnam(pwent->pw_name); + if (which == OP_GPWNAM) { + if (pwent) + spwent = getspnam(pwent->pw_name); + } # ifdef HAS_GETSPUID /* AFAIK there isn't any anywhere. --jhi */ - else if (which == OP_GPWUID) - spwent = getspnam(pwent->pw_name); + else if (which == OP_GPWUID) { + if (pwent) + spwent = getspnam(pwent->pw_name); + } # endif - else - spwent = (struct spwd *)getspent(); + else + spwent = (struct spwd *)getspent(); #endif EXTEND(SP, 10); |