From ceaff03b27d3e5be9263c980ce8006854c4bff60 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 7 Sep 2012 11:00:54 +0200 Subject: [PATCH] libblkid: check fchmod() return value [coverity scan] --- libblkid/src/save.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } } -- 2.47.3