Skip to content

Commit

Permalink
Merge pull request #203 from nasa/177-2-null-pointer-dereference-in-c…
Browse files Browse the repository at this point in the history
…rypto_check_anti_replay

#177 Fix - per SpicyDLL - solves possibility of sa NULL dereference
  • Loading branch information
jlucas9 committed Oct 19, 2023
2 parents 016729b + a747faa commit 8ea632e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down

0 comments on commit 8ea632e

Please sign in to comment.