mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
sd-bus: use INC_SAFE and assert for message_from_header allocation
Coverity flags ALIGN() as potentially returning SIZE_MAX and the
subsequent a += label_sz + 1 as overflowing. Assert ALIGN result
is not SIZE_MAX and use INC_SAFE for the addition.
CID#1548030
Follow-up for 55354d5930
This commit is contained in:
@@ -359,12 +359,12 @@ static int message_from_header(
|
||||
/* Note that we are happy with unknown flags in the flags header! */
|
||||
|
||||
a = ALIGN(sizeof(sd_bus_message));
|
||||
/* Silence static analyzers, ALIGN cannot overflow for sizeof() */
|
||||
assert(a != SIZE_MAX);
|
||||
|
||||
if (label) {
|
||||
label_sz = strlen(label);
|
||||
/* Silence static analyzers */
|
||||
assert(label_sz <= SIZE_MAX - ALIGN(sizeof(sd_bus_message)) - 1);
|
||||
a += label_sz + 1;
|
||||
assert_se(INC_SAFE(&a, label_sz + 1));
|
||||
}
|
||||
|
||||
m = malloc0(a);
|
||||
|
||||
Reference in New Issue
Block a user