From: Yu Watanabe Date: Fri, 17 Apr 2026 22:21:38 +0000 (+0900) Subject: iovec-util: add overflow check in iovec_total_size() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9628b3118628343f6e156d49b9f2de040f6d675b;p=thirdparty%2Fsystemd.git iovec-util: add overflow check in iovec_total_size() Mostly theoretical. But for safety. --- diff --git a/src/basic/iovec-util.c b/src/basic/iovec-util.c index ec8af57e642..cd2c1a736e8 100644 --- a/src/basic/iovec-util.c +++ b/src/basic/iovec-util.c @@ -21,8 +21,11 @@ size_t iovec_total_size(const struct iovec *iovec, size_t n) { assert(iovec || n == 0); - FOREACH_ARRAY(j, iovec, n) + FOREACH_ARRAY(j, iovec, n) { + if (j->iov_len > SIZE_MAX - sum) + return SIZE_MAX; /* Indicate overflow. */ sum += j->iov_len; + } return sum; }