libc: getlogin should not query fd directly

This commit is contained in:
K. Lange 2018-10-31 11:30:17 +09:00
parent be97496bed
commit 0762fb30ce

View File

@ -20,9 +20,12 @@ char * getlogin(void) {
}
}
char * name = ttyname(tty);
if (!name) return NULL;
/* Get the owner */
struct stat statbuf;
fstat(tty, &statbuf);
stat(name, &statbuf);
struct passwd * passwd = getpwuid(statbuf.st_uid);