]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: check fchmod() return value [coverity scan]
authorKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 09:00:54 +0000 (11:00 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 09:01:07 +0000 (11:01 +0200)
libblkid/src/save.c

index f0008ae53e6c470ede80589779e7685c3e06696c..7ce6fa498e33f863db7f65b3ef625b713ff6ce34 100644 (file)
@@ -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);
                }
        }