[PATCH v2] cpukit/libmisc/uuid: Check for invalid FD

Kinsey Moore kinsey.moore at oarcorp.com
Tue Jan 16 23:55:58 UTC 2024


---
 cpukit/libmisc/uuid/gen_uuid.c | 6 ++++++
 1 file changed, 6 insertions(+)

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;
-- 
2.39.2



More information about the devel mailing list