Skip to content

Commit b629d09

Browse files
committed
sd-bus: check for potential integer overflow in KDBUS_ITEM_FOREACH()
For large values of item->size, the 'part' pointer can wrap around, which results in an illegal pointer, but currently passes the for-loop condition.
1 parent 2a781fc commit b629d09

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libsystemd/sd-bus/bus-kernel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
#define KDBUS_ITEM_FOREACH(part, head, first) \
3333
for (part = (head)->first; \
34-
(uint8_t *)(part) < (uint8_t *)(head) + (head)->size; \
34+
((uint8_t *)(part) < (uint8_t *)(head) + (head)->size) && \
35+
((uint8_t *) part >= (uint8_t *) head); \
3536
part = KDBUS_ITEM_NEXT(part))
3637

3738
#define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data)

0 commit comments

Comments
 (0)