cpukit/libmisc/uuid: Check for invalid FD

This commit is contained in:
Kinsey Moore
2024-01-16 14:32:35 -06:00
committed by Joel Sherrill
parent 487cdce64d
commit df8e3fcbb6

View File

@@ -343,11 +343,17 @@ 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);
#ifdef __rtems__
if (state_fd >= 0) {
#endif
state_f = fdopen(state_fd, "r+");
if (!state_f) {
close(state_fd);
state_fd = -1;
}
#ifdef __rtems__
}
#endif
}
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;