commit 3669fa411773c56044b0e9027fdcc6290631a173
parent 53547b783535e2f184875f1b9ca240472b890218
Author: sin <sin@2f30.org>
Date: Wed, 2 Jul 2014 11:51:30 +0100
More error checking for fwrite()
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/login.c b/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);