From: Theodore Ts'o Date: Sat, 11 Jan 2014 03:09:45 +0000 (-0500) Subject: libblkid: add error checking for rename() while saving the blkid cache X-Git-Tag: v1.42.10~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d719bad862a6b900089cb9bd4e34d99d4c84746;p=thirdparty%2Fe2fsprogs.git libblkid: add error checking for rename() while saving the blkid cache Addresses-Coverity-Id: #1049141 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/blkid/save.c b/lib/blkid/save.c index c55e0437e..a6538db6a 100644 --- a/lib/blkid/save.c +++ b/lib/blkid/save.c @@ -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)); }