diff options
author | James Prestwood <prestwoj@gmail.com> | 2024-02-27 11:35:21 -0800 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-02-27 14:33:33 -0600 |
commit | ee52968043048e706b317855ce92bc9e9c8320c9 (patch) | |
tree | e08a6a7836311049f1666c3fc86d764c6e12b0a5 | |
parent | d13af0a4a2ec03103d56daf92f7ab91da8fed3b0 (diff) |
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.
-rw-r--r-- | src/crypto.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/crypto.c b/src/crypto.c index 3128b2a52..7235e3c2a 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -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; |