3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 04:32:37 +01:00

crypto: fix uninitialized variable coverity warning

For some encrypt operations DPP passes no AD iovecs (both are
NULL/0). But since the iovec itself is on the stack 'ad' is a
valid pointer from within aes_siv_encrypt. This causes memcpy
to be called which coverity complains about. Since the copy
length is zero it was effectively a no-op, but check num_ad to
prevent the call.
This commit is contained in:
James Prestwood 2024-02-27 11:35:21 -08:00 committed by Denis Kenzior
parent d13af0a4a2
commit ee52968043

View File

@ -331,7 +331,7 @@ bool aes_siv_encrypt(const void *key, size_t key_len, const void *in,
struct iovec iov[num_ad + 1];
uint8_t v[16];
if (ad)
if (ad && num_ad)
memcpy(iov, ad, sizeof(struct iovec) * num_ad);
iov[num_ad].iov_base = (void *)in;