diff options
author | Denis Kenzior <denkenz@gmail.com> | 2023-04-13 22:36:42 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2023-04-16 11:26:22 -0500 |
commit | 6d4616aac30009ad514434b82ae9793f904415e3 (patch) | |
tree | ed08765783035e59064bc38261f3eb403e12a8f6 | |
parent | 1122d699c454ef26e2028dc7b8f50bd4a40d9bfd (diff) |
cipher: If in is null, skip adding it to iovec
Be pedantic and skip adding 'in' to the iovec in operate_cipher() if the
in variable is NULL. It is up to callers of operate_cipher to enforce
how 'in' is used, in particular l_aead_cipher_encrypt already does so.
-rw-r--r-- | ell/cipher.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ell/cipher.c b/ell/cipher.c index 6b8528c2..0e4244f7 100644 --- a/ell/cipher.c +++ b/ell/cipher.c @@ -338,9 +338,14 @@ static ssize_t operate_cipher(int sk, __u32 operation, iov[0].iov_base = (void *) ad; iov[0].iov_len = ad_len; - iov[1].iov_base = (void *) in; - iov[1].iov_len = in_len; - msg.msg_iovlen = 2; + + msg.msg_iovlen = 1; + + if (in) { + iov[1].iov_base = (void *) in; + iov[1].iov_len = in_len; + msg.msg_iovlen = 2; + } } else { iov[0].iov_base = (void *) in; iov[0].iov_len = in_len; |