From b15fb734cc4619a90badb48920aa697f4aef0355 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 26 Jan 2015 19:24:12 +0100 Subject: [PATCH] test: add check for pointer arithmetic overflow It's not crucial to have this in the test suite, but we should follow our own examples. Signed-off-by: Daniel Mack --- test/kdbus-util.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/kdbus-util.h b/test/kdbus-util.h index 5f30aa8..d052fd8 100644 --- a/test/kdbus-util.h +++ b/test/kdbus-util.h @@ -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)) -- 2.34.1