mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
sd-bus: add assert_cc for message allocation size
Use CONST_ALIGN_TO to express the compile-time overflow check for
the ALIGN(sizeof(sd_bus_message)) + sizeof(BusMessageHeader)
allocation, since ALIGN() is not constexpr.
CID#1548031
Follow-up for de1c301ed1
This commit is contained in:
@@ -464,6 +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);
|
||||
sd_bus_message *t = malloc0(ALIGN(sizeof(sd_bus_message)) + sizeof(BusMessageHeader));
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user