Skip to content

Commit

Permalink
XXX need to StructCopy pp_sys mutexes
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed May 5, 2021
1 parent 63752ae commit 24a9fd1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pp_sys.c
Expand Up @@ -5448,20 +5448,29 @@ PP(pp_gpwent)
case OP_GPWNAM:
{
const char* const name = POPpbytex;
/* XXX need to copy if non-reentrant before releasing mutex */
GETPWNAM_LOCK;
pwent = getpwnam(name);
GETPWNAM_UNLOCK;
}
break;
case OP_GPWUID:
{
Uid_t uid = POPi;
GETPWUID_LOCK;
pwent = getpwuid(uid);
GETPWUID_UNLOCK;
}
break;
case OP_GPWENT:
# ifdef HAS_GETPWENT
pwent = getpwent();
#ifdef POSIX_BC /* In some cases pw_passwd has invalid addresses */
if (pwent) pwent = getpwnam(pwent->pw_name);
if (pwent) {
GETPWNAM_LOCK;
pwent = getpwnam(pwent->pw_name);
GETPWNAM_UNLOCK;
}
#endif
# else
DIE(aTHX_ PL_no_func, "getpwent");
Expand Down Expand Up @@ -5506,15 +5515,18 @@ PP(pp_gpwent)
* has a different API than the Solaris/IRIX one. */
# if defined(HAS_GETSPNAM) && !defined(_AIX)
{
const struct spwd * spwent;
dSAVE_ERRNO;
const struct spwd * const spwent = getspnam(pwent->pw_name);
GETSPNAM_LOCK;
spwent = getspnam(pwent->pw_name);
/* Save and restore errno so that
* underprivileged attempts seem
* to have never made the unsuccessful
* attempt to retrieve the shadow password. */
RESTORE_ERRNO;
if (spwent && spwent->sp_pwdp)
sv_setpv(sv, spwent->sp_pwdp);
GETSPNAM_UNLOCK;
}
# endif
# ifdef PWPASSWD
Expand Down

0 comments on commit 24a9fd1

Please sign in to comment.