mirror of https://github.com/vitalif/e2fsprogs
libuuid: add error checking to syscalls in get_clock()
Also remove redundant close() of state_fd, since the fclose() of state_f will result in the fd being closed. Addresses-Coverity-Id: #1049146 Addresses-Coverity-Id: #26092 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>maint-test
parent
2500ebfc89
commit
f7d7905976
|
@ -326,10 +326,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 >= 0) {
|
||||
state_f = fdopen(state_fd, "r+");
|
||||
if (!state_f) {
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
fl.l_type = F_WRLCK;
|
||||
|
@ -343,7 +345,6 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
|
|||
if ((errno == EAGAIN) || (errno == EINTR))
|
||||
continue;
|
||||
fclose(state_f);
|
||||
close(state_fd);
|
||||
state_fd = -1;
|
||||
break;
|
||||
}
|
||||
|
@ -412,7 +413,10 @@ try_again:
|
|||
}
|
||||
rewind(state_f);
|
||||
fl.l_type = F_UNLCK;
|
||||
fcntl(state_fd, F_SETLK, &fl);
|
||||
if (fcntl(state_fd, F_SETLK, &fl) < 0) {
|
||||
fclose(state_f);
|
||||
state_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
*clock_high = clock_reg >> 32;
|
||||
|
|
Loading…
Reference in New Issue