* src/vipw.c: Make sure opened files are closed.

This commit is contained in:
nekral-guest 2009-05-25 19:51:23 +00:00
parent 401d72d609
commit a6418fb0df
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2009-05-25 Nicolas François <nicolas.francois@centraliens.net>
* src/vipw.c: Make sure opened files are closed.
2009-05-25 Nicolas François <nicolas.francois@centraliens.net>
* man/chpasswd.8.xml, man/grpck.8.xml, man/newgrp.1.xml,

View File

@ -116,8 +116,12 @@ static int create_backup_file (FILE * fp, const char *backup, struct stat *sb)
unlink (backup);
return -1;
}
if ( (fsync (fileno (bkfp)) != 0)
|| (fclose (bkfp) != 0)) {
if (fsync (fileno (bkfp)) != 0) {
(void) fclose (bkfp);
unlink (backup);
return -1;
}
if (fclose (bkfp) != 0) {
unlink (backup);
return -1;
}
@ -225,6 +229,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
if (create_backup_file (f, fileedit, &st1) != 0) {
vipwexit (_("Couldn't make backup"), errno, 1);
}
(void) fclose (f);
createedit = true;
editor = getenv ("VISUAL");