diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2024-01-16 14:32:35 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2024-01-22 09:56:40 -0600 |
commit | df8e3fcbb686c0f8afb3b4eb9942256d02ddcb87 (patch) | |
tree | 23d55f86644c6a56d337fd53490b787de4f59865 | |
parent | cpukit/dosfs: Don't leak a FAT FD (diff) | |
download | rtems-df8e3fcbb686c0f8afb3b4eb9942256d02ddcb87.tar.bz2 |
cpukit/libmisc/uuid: Check for invalid FD
-rw-r--r-- | cpukit/libmisc/uuid/gen_uuid.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c index 71b8a569bb..9b8dbeaa2e 100644 --- a/cpukit/libmisc/uuid/gen_uuid.c +++ b/cpukit/libmisc/uuid/gen_uuid.c @@ -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; |