mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-24 01:57:06 +01:00
getpwnam(3) may return NULL.
Requested by: nork Reviewed by: Takeharu KATO <takeharu1219__at__ybb.ne.jp>, nork MFC after: 1 week
This commit is contained in:
parent
4aa18e9d93
commit
3db78cf013
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220055
@ -149,7 +149,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
static char *cleanenv;
|
||||
struct passwd *pwd;
|
||||
struct passwd *pwd = NULL;
|
||||
struct pam_conv conv = { openpam_ttyconv, NULL };
|
||||
enum tristate iscsh;
|
||||
login_cap_t *lc;
|
||||
@ -255,8 +255,9 @@ main(int argc, char *argv[])
|
||||
/* get current login name, real uid and shell */
|
||||
ruid = getuid();
|
||||
username = getlogin();
|
||||
pwd = getpwnam(username);
|
||||
if (username == NULL || pwd == NULL || pwd->pw_uid != ruid)
|
||||
if (username != NULL)
|
||||
pwd = getpwnam(username);
|
||||
if (pwd == NULL || pwd->pw_uid != ruid)
|
||||
pwd = getpwuid(ruid);
|
||||
if (pwd == NULL) {
|
||||
#ifdef USE_BSM_AUDIT
|
||||
|
Loading…
Reference in New Issue
Block a user