aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-05-13 15:28:11 +0300
committerMatias Elo <matias.elo@nokia.com>2024-06-05 13:11:13 +0300
commit5739154a4823768d11a0b3a0c41e356526c6fa13 (patch)
tree78348f3d8179cdca47c6e5e847e513dbb2fdd242
parent12a5d436171a132fd5b0ad7a3a418256ccbcb02a (diff)
linux-dpdk: crypto: avoid passing null pointer to memcpy()
Fixes GCC sanitizer error: "null pointer passed as argument 2, which is declared to never be null". Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r--platform/linux-dpdk/odp_crypto.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/platform/linux-dpdk/odp_crypto.c b/platform/linux-dpdk/odp_crypto.c
index 9555101a7..5ce9699f3 100644
--- a/platform/linux-dpdk/odp_crypto.c
+++ b/platform/linux-dpdk/odp_crypto.c
@@ -1738,9 +1738,11 @@ static void crypto_fill_sym_param(const crypto_session_entry_t *session,
_ODP_ASSERT(cipher_iv_len == 0 || param->cipher_iv_ptr != NULL);
_ODP_ASSERT(auth_iv_len == 0 || param->auth_iv_ptr != NULL);
- iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
- memcpy(iv_ptr, param->cipher_iv_ptr, cipher_iv_len);
+ if (cipher_iv_len > 0) {
+ iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET);
+ memcpy(iv_ptr, param->cipher_iv_ptr, cipher_iv_len);
+ }
if (odp_unlikely(auth_iv_len > 0)) {
iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET + MAX_IV_LENGTH);
memcpy(iv_ptr, param->auth_iv_ptr, auth_iv_len);