aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/crypto/crypto.c
diff options
context:
space:
mode:
authorDmitry Valter <d-valter@yandex-team.com>2023-10-05 08:31:23 +0000
committerDamjan Marion <dmarion@0xa5.net>2023-10-24 22:13:43 +0000
commite8e4b5f9af01b1afa5ba90f0e61fbf924c1c667b (patch)
tree345b11e681f9405ebd15d55223ff7aa26c24a7e6 /src/vnet/crypto/crypto.c
parent6b027cfdbcb750b8aa1b8ab9a3904c1b2dca6f15 (diff)
crypto: fix algo selection
Check if crypto ops vector is matching actual ops instead if blindly dereferencing it. Type: fix Signed-off-by: Dmitry Valter <d-valter@yandex-team.com> Change-Id: Ib88ab44137d9360ee96228e72349a62b2fa7a7e0
Diffstat (limited to 'src/vnet/crypto/crypto.c')
-rw-r--r--src/vnet/crypto/crypto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/vnet/crypto/crypto.c b/src/vnet/crypto/crypto.c
index 0f9949297a7..3cada7591b1 100644
--- a/src/vnet/crypto/crypto.c
+++ b/src/vnet/crypto/crypto.c
@@ -192,13 +192,16 @@ vnet_crypto_is_set_handler (vnet_crypto_alg_t alg)
vnet_crypto_op_id_t opt = 0;
int i;
- if (alg > vec_len (cm->algs))
+ if (alg >= vec_len (cm->algs))
return 0;
for (i = 0; i < VNET_CRYPTO_OP_N_TYPES; i++)
if ((opt = cm->algs[alg].op_by_type[i]) != 0)
break;
+ if (opt >= vec_len (cm->ops_handlers))
+ return 0;
+
return NULL != cm->ops_handlers[opt];
}