mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
sd-bus: assert ALIGN8 result is not SIZE_MAX
Coverity flags sizeof(BusMessageHeader) + ALIGN8(m->fields_size)
as overflowing because ALIGN_TO can return SIZE_MAX as an overflow
sentinel. Assert that the aligned value is not SIZE_MAX to prove
the addition is safe.
CID#1548023
CID#1548046
Follow-up for 2ac7c17f9d
This commit is contained in:
@@ -153,7 +153,8 @@ static inline uint64_t BUS_MESSAGE_COOKIE(sd_bus_message *m) {
|
||||
}
|
||||
|
||||
static inline size_t BUS_MESSAGE_SIZE(sd_bus_message *m) {
|
||||
/* Silence static analyzers */
|
||||
/* Silence static analyzers, fields_size is validated at message creation */
|
||||
assert(ALIGN8(m->fields_size) != SIZE_MAX);
|
||||
assert(ALIGN8(m->fields_size) <= SIZE_MAX - sizeof(BusMessageHeader));
|
||||
assert(m->body_size <= SIZE_MAX - sizeof(BusMessageHeader) - ALIGN8(m->fields_size));
|
||||
return
|
||||
@@ -163,7 +164,8 @@ static inline size_t BUS_MESSAGE_SIZE(sd_bus_message *m) {
|
||||
}
|
||||
|
||||
static inline size_t BUS_MESSAGE_BODY_BEGIN(sd_bus_message *m) {
|
||||
/* Silence static analyzers */
|
||||
/* Silence static analyzers, fields_size is validated at message creation */
|
||||
assert(ALIGN8(m->fields_size) != SIZE_MAX);
|
||||
assert(ALIGN8(m->fields_size) <= SIZE_MAX - sizeof(BusMessageHeader));
|
||||
return
|
||||
sizeof(BusMessageHeader) +
|
||||
|
||||
Reference in New Issue
Block a user