1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

setup_utmp: add error check in case getpwuid fails.

Spotted by Coverity: if there is no password file entry associated
with our numeric uid, we'll press on anyway and dereference NULL.
This commit is contained in:
Simon Tatham 2020-06-16 17:47:20 +01:00
parent 4ea56076a8
commit caf4802b0a

View File

@ -206,6 +206,8 @@ static void setup_utmp(char *ttyname, char *location)
struct timeval tv;
pw = getpwuid(getuid());
if (!pw)
return; /* can't stamp utmp if we don't have a username */
memset(&utmp_entry, 0, sizeof(utmp_entry));
utmp_entry.ut_type = USER_PROCESS;
utmp_entry.ut_pid = getpid();