From: Luca Boccassi Date: Sat, 28 Mar 2026 20:10:14 +0000 (+0000) Subject: importd: add assert for log_message_size accumulation bounds X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2bd6930efeace1ef0bae4683ef38e9ad6f74dcd0;p=thirdparty%2Fsystemd.git importd: add assert for log_message_size accumulation bounds Coverity flags log_message_size += l as a potential overflow, but l is bounded by the read() count parameter which is sizeof(log_message) - log_message_size. Add an assert to make this invariant explicit. CID#1548062 Follow-up for 3d7415f43f0fe6a821d7bc4a341ba371e8a30ef3 --- diff --git a/src/import/importd.c b/src/import/importd.c index d3363d446cb..fed2af41701 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -418,6 +418,8 @@ static int transfer_on_log(sd_event_source *s, int fd, uint32_t revents, void *u return 0; } + /* Silence static analyzers, l is bounded by read() count: sizeof - log_message_size */ + assert((size_t) l <= sizeof(t->log_message) - t->log_message_size); t->log_message_size += l; transfer_send_logs(t, false);