creds-util: add assert for output buffer size overflow safety
Coverity flags the multi-term output.iov_len accumulation as a
potential overflow. Add an assert after the calculation to verify
the result is at least as large as the input, catching wraparound.
CID#1548068
Follow-up for 21bc0b6fa1
This commit is contained in:
@@ -1068,6 +1068,8 @@ int encrypt_credential_and_warn(
|
||||
ALIGN8(offsetof(struct metadata_credential_header, name) + strlen_ptr(name)) +
|
||||
input->iov_len + 2U * (size_t) bsz +
|
||||
tsz;
|
||||
/* Silence static analyzers */
|
||||
assert(output.iov_len >= input->iov_len);
|
||||
|
||||
output.iov_base = malloc0(output.iov_len);
|
||||
if (!output.iov_base)
|
||||
|
||||
Reference in New Issue
Block a user