]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: add assert_cc for message allocation size
authorLuca Boccassi <luca.boccassi@gmail.com>
Sat, 28 Mar 2026 21:41:02 +0000 (21:41 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 30 Mar 2026 08:37:32 +0000 (09:37 +0100)
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 de1c301ed165eb4d04a0c9d4babe97912b5233bb

src/libsystemd/sd-bus/bus-message.c

index 1f278db54e57e064b3eb4bad0d49acfb0363972b..507c5d7ff40600b2ee26a8627bae4c78aafb2167 100644 (file)
@@ -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;