mirror of git://git.suckless.org/ubase
Only call fwrite() and fclose() when fp is not NULL
Spotted by Hiltjo.
This commit is contained in:
parent
3669fa4117
commit
c9609ea5ff
6
login.c
6
login.c
|
@ -89,12 +89,14 @@ main(int argc, char *argv[])
|
|||
usr.ut_tv.tv_sec = time(NULL);
|
||||
|
||||
fp = fopen(UTMP_PATH, "a");
|
||||
if (!fp)
|
||||
weprintf("fopen %s:", UTMP_PATH);
|
||||
if (fp) {
|
||||
if (fwrite(&usr, sizeof(usr), 1, fp) != 1)
|
||||
if (ferror(fp))
|
||||
weprintf("%s: write error:", UTMP_PATH);
|
||||
fclose(fp);
|
||||
} else {
|
||||
weprintf("fopen %s:", UTMP_PATH);
|
||||
}
|
||||
|
||||
return dologin(pw, pflag);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue