test: add check for pointer arithmetic overflow
authorDaniel Mack <daniel@zonque.org>
Mon, 26 Jan 2015 18:24:12 +0000 (19:24 +0100)
committerDaniel Mack <daniel@zonque.org>
Mon, 26 Jan 2015 18:24:12 +0000 (19:24 +0100)
It's not crucial to have this in the test suite, but we should follow
our own examples.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test/kdbus-util.h

index 5f30aa8ea20c2d7cb594325c369b73e292d69a10..d052fd8b3ed7bc21361fbb4184efcb132109bbe8 100644 (file)
@@ -29,7 +29,8 @@
        (typeof(item))(((uint8_t *)item) + KDBUS_ALIGN8((item)->size))
 #define KDBUS_ITEM_FOREACH(item, head, first)                          \
        for (item = (head)->first;                                      \
-            (uint8_t *)(item) < (uint8_t *)(head) + (head)->size;      \
+            ((uint8_t *)(item) < (uint8_t *)(head) + (head)->size) &&  \
+              ((uint8_t *)(item) >= (uint8_t *)(head));        \
             item = KDBUS_ITEM_NEXT(item))