mirror of git://git.suckless.org/ubase
More error checking for fwrite()
This commit is contained in:
parent
53547b7835
commit
3669fa4117
4
login.c
4
login.c
|
@ -91,7 +91,9 @@ main(int argc, char *argv[])
|
|||
fp = fopen(UTMP_PATH, "a");
|
||||
if (!fp)
|
||||
weprintf("fopen %s:", UTMP_PATH);
|
||||
fwrite(&usr, sizeof(usr), 1, fp);
|
||||
if (fwrite(&usr, sizeof(usr), 1, fp) != 1)
|
||||
if (ferror(fp))
|
||||
weprintf("%s: write error:", UTMP_PATH);
|
||||
fclose(fp);
|
||||
|
||||
return dologin(pw, pflag);
|
||||
|
|
Loading…
Reference in New Issue