From: Karel Zak Date: Fri, 7 Sep 2012 09:00:54 +0000 (+0200) Subject: libblkid: check fchmod() return value [coverity scan] X-Git-Tag: v2.23-rc1~719 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ceaff03b27d3e5be9263c980ce8006854c4bff60;p=thirdparty%2Futil-linux.git libblkid: check fchmod() return value [coverity scan] --- diff --git a/libblkid/src/save.c b/libblkid/src/save.c index f0008ae53e..7ce6fa498e 100644 --- a/libblkid/src/save.c +++ b/libblkid/src/save.c @@ -110,10 +110,13 @@ int blkid_flush_cache(blkid_cache cache) sprintf(tmp, "%s-XXXXXX", filename); fd = mkstemp(tmp); if (fd >= 0) { - file = fdopen(fd, "w"); - opened = tmp; + if (fchmod(fd, 0644) != 0) + DBG(DEBUG_SAVE, printf("%s: fchmod failed\n", filename)); + else if ((file = fdopen(fd, "w"))) + opened = tmp; + if (!file) + close(fd); } - fchmod(fd, 0644); } }