From 8a00b3fe636d81f3192ccc20d9ffd8bdbcf2f355 Mon Sep 17 00:00:00 2001 From: Lin Bai Date: Mon, 10 Aug 2020 18:52:22 +0800 Subject: [PATCH] qcacld-3.0: Avoid to use incorrect key length Current parameter passed to lim_get_crypto_digest_len will be either SHA386 or SHA256, won't return -EINVAL in any case. For later considering, return 0 if parameter not the 2 crypto types. Change-Id: I6cd7481a06106138df7ba18fbe9ed4eece246607 CRs-Fixed: 2751809 --- core/mac/src/pe/lim/lim_process_fils.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/mac/src/pe/lim/lim_process_fils.c b/core/mac/src/pe/lim/lim_process_fils.c index 5596491a0d58..1f2f2706d353 100644 --- a/core/mac/src/pe/lim/lim_process_fils.c +++ b/core/mac/src/pe/lim/lim_process_fils.c @@ -61,7 +61,8 @@ static int lim_get_crypto_digest_len(uint8_t *type) return SHA384_DIGEST_SIZE; else if (!strcmp(type, HMAC_SHA256_CRYPTO_TYPE)) return SHA256_DIGEST_SIZE; - return -EINVAL; + + return 0; } /** @@ -283,6 +284,11 @@ static QDF_STATUS lim_get_key_from_prf(uint8_t *type, uint8_t *secret, uint8_t crypto_digest_len = lim_get_crypto_digest_len(type); uint8_t tmp_hash[SHA384_DIGEST_SIZE] = {0}; + if (!crypto_digest_len) { + pe_err("Incorrect crypto length"); + return QDF_STATUS_E_FAILURE; + } + addr[0] = count; len[0] = sizeof(count);