]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: do not use invalid file descriptor
authorPetr Uzel <petr.uzel@suse.cz>
Mon, 14 Feb 2011 13:43:25 +0000 (14:43 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Feb 2011 15:07:15 +0000 (16:07 +0100)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
shlibs/uuid/src/gen_uuid.c

index a27d49c96d0bdda0ef5629a559c4582d57927d21..6e82a7b7cb8c28eafa45111c69aecb7f60b28b9e 100644 (file)
@@ -324,10 +324,12 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
                state_fd = open("/var/lib/libuuid/clock.txt",
                                O_RDWR|O_CREAT, 0660);
                (void) umask(save_umask);
-               state_f = fdopen(state_fd, "r+");
-               if (!state_f) {
-                       close(state_fd);
-                       state_fd = -1;
+               if (state_fd != -1) {
+                       state_f = fdopen(state_fd, "r+");
+                       if (!state_f) {
+                               close(state_fd);
+                               state_fd = -1;
+                       }
                }
        }
        if (state_fd >= 0) {