Module: xenomai-3
Branch: next
Commit: 3e8a9fd398b98482e989b97d4fd721fbff868ecd
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e8a9fd398b98482e989b97d4fd721fbff868ecd

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Nov 11 10:52:40 2016 +0100

cobalt/posix/clock: uapi: strengthen test for external clock ids

__COBALT_CLOCK_EXT_P() was way too weak in filtering out invalid clock
ids, also returning a true value for identifiers being obviously out
of range although bit #6 is raised.

This would cause all clock* services depending on such detection to
crash badly due to using bad index values determined from invalid
clock ids they should never have considered in the first place.

The test is strengthened by comparing the clock identifier to the
valid range explicitly, i.e. [ 64...127 ] inclusive.

---

 include/cobalt/uapi/time.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/cobalt/uapi/time.h b/include/cobalt/uapi/time.h
index 4a3679b..411baf5 100644
--- a/include/cobalt/uapi/time.h
+++ b/include/cobalt/uapi/time.h
@@ -41,7 +41,7 @@
 #define COBALT_MAX_EXTCLOCKS  64
 
 #define __COBALT_CLOCK_EXT(nr)         ((clockid_t)(nr) | (1 << 6))
-#define __COBALT_CLOCK_EXT_P(id)       ((int)(id) & (1 << 6))
+#define __COBALT_CLOCK_EXT_P(id)       ((int)(id) >= 64 && (int)(id) < 128)
 #define __COBALT_CLOCK_EXT_INDEX(id)   ((int)(id) & ~(1 << 6))
 
 /*


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to