mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
sd-bus: assert ALIGN result in sd_bus_message_new
Coverity flags ALIGN(sizeof(sd_bus_message)) as potentially
returning SIZE_MAX, making the subsequent + sizeof(BusMessageHeader)
overflow. Store the ALIGN result in a local and assert it is not
SIZE_MAX.
CID#1548031
Follow-up for 4f5b28b72c
This commit is contained in:
@@ -464,8 +464,8 @@ _public_ int sd_bus_message_new(
|
||||
/* Creation of messages with _SD_BUS_MESSAGE_TYPE_INVALID is allowed. */
|
||||
assert_return(type < _SD_BUS_MESSAGE_TYPE_MAX, -EINVAL);
|
||||
|
||||
/* Silence static analyzers */
|
||||
assert_cc(sizeof(sd_bus_message) + sizeof(void*) + sizeof(BusMessageHeader) <= SIZE_MAX);
|
||||
/* Silence static analyzers, ALIGN cannot overflow for sizeof() */
|
||||
assert(ALIGN(sizeof(sd_bus_message)) != SIZE_MAX);
|
||||
sd_bus_message *t = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(BusMessageHeader));
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user