More error checking for fwrite()

This commit is contained in:
sin 2014-07-02 11:51:30 +01:00
parent 53547b7835
commit 3669fa4117
1 changed files with 3 additions and 1 deletions

View File

@ -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);