From: Petr Uzel Date: Mon, 14 Feb 2011 13:43:25 +0000 (+0100) Subject: libuuid: do not use invalid file descriptor X-Git-Tag: v2.20-rc1~560 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20c04820d16673901ade8b344aa745d1d3a8876d;p=thirdparty%2Futil-linux.git libuuid: do not use invalid file descriptor Signed-off-by: Petr Uzel --- diff --git a/shlibs/uuid/src/gen_uuid.c b/shlibs/uuid/src/gen_uuid.c index a27d49c96d..6e82a7b7cb 100644 --- a/shlibs/uuid/src/gen_uuid.c +++ b/shlibs/uuid/src/gen_uuid.c @@ -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) {