From a747faab597856ffd85e37e8839b46d92374823f Mon Sep 17 00:00:00 2001 From: Robert Brown Date: Fri, 13 Oct 2023 11:31:43 -0400 Subject: [PATCH] #177 Fix/Improvement - per SpicyDLL --- src/core/crypto.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/crypto.c b/src/core/crypto.c index fd3218aa..c5aefce4 100644 --- a/src/core/crypto.c +++ b/src/core/crypto.c @@ -812,6 +812,10 @@ int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t* sa_ptr, uint8_t* arsn, u int8_t ARSN_VALID = -1; // Check for NULL pointers + if (sa_ptr == NULL) // #177 - Modification made per suggestion of 'Spicydll' - prevents null dereference + { + return CRYPTO_LIB_ERR_NULL_SA; + } if (arsn == NULL && sa_ptr->arsn_len > 0) { return CRYPTO_LIB_ERR_NULL_ARSN; @@ -820,10 +824,7 @@ int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t* sa_ptr, uint8_t* arsn, u { return CRYPTO_LIB_ERR_NULL_IV; } - if (sa_ptr == NULL) - { - return CRYPTO_LIB_ERR_NULL_SA; - } + // If sequence number field is greater than zero, check for replay if (sa_ptr->shsnf_len > 0) {