]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/commonio.c: Unlink backup file on error
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 11 Jan 2026 22:18:48 +0000 (23:18 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Wed, 14 Jan 2026 12:05:45 +0000 (13:05 +0100)
It doesn't make sense to keep a file around if it's not even a proper
backup.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/commonio.c

index 2f278df267d61b4606108e770c6b32360df112ae..846372b125519f9e0035b045dd7f90e877d57e1d 100644 (file)
@@ -299,16 +299,16 @@ static int create_backup (const char *backup, FILE * fp)
        }
        if ((c != EOF) || (ferror (fp) != 0) || (fflush (bkfp) != 0)) {
                (void) fclose (bkfp);
-               /* FIXME: unlink the backup file? */
+               unlink(backup);
                return -1;
        }
        if (fsync (fileno (bkfp)) != 0) {
                (void) fclose (bkfp);
-               /* FIXME: unlink the backup file? */
+               unlink(backup);
                return -1;
        }
        if (fclose (bkfp) != 0) {
-               /* FIXME: unlink the backup file? */
+               unlink(backup);
                return -1;
        }