diff --git a/pwutil.c b/pwutil.c index 7df9fbe8d..e6d53a8a4 100644 --- a/pwutil.c +++ b/pwutil.c @@ -264,8 +264,8 @@ sudo_getpwnam(name) * Cache passwd db entry if it exists or a negative response if not. */ if ((pw = getpwnam(name)) != NULL) { - pw->pw_passwd = sudo_getepw(pw); /* get shadow password */ pw = sudo_pwdup(pw); + pw->pw_passwd = sudo_getepw(pw); /* get shadow password */ if (rbinsert(pwcache_byname, (VOID *) pw) != NULL) errorx(1, "unable to cache user name, already exists"); if (rbinsert(pwcache_byuid, (VOID *) pw) != NULL)