]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libblkid: add error checking for rename() while saving the blkid cache
authorTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jan 2014 03:09:45 +0000 (22:09 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jan 2014 03:09:45 +0000 (22:09 -0500)
Addresses-Coverity-Id: #1049141

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/save.c

index c55e0437ec9686a53bda3c19fa7a2931d7fa6f13..a6538db6aec79fca33d3300e676552a817edcb94 100644 (file)
@@ -136,7 +136,7 @@ int blkid_flush_cache(blkid_cache cache)
        fclose(file);
        if (opened != filename) {
                if (ret < 0) {
-                       unlink(opened);
+                       (void) unlink(opened);
                        DBG(DEBUG_SAVE,
                            printf("unlinked temp cache %s\n", opened));
                } else {
@@ -149,7 +149,8 @@ int blkid_flush_cache(blkid_cache cache)
                                link(filename, backup);
                                free(backup);
                        }
-                       rename(opened, filename);
+                       if (rename(opened, filename) < 0)
+                               (void) unlink(opened);
                        DBG(DEBUG_SAVE,
                            printf("moved temp cache %s\n", opened));
                }