You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed some code that could allow for a null pointer to be dereferenced in src/src_main/crypto.c
int32_tCrypto_Check_Anti_Replay(SecurityAssociation_t*sa_ptr, uint8_t*arsn, uint8_t*iv)
{
int32_tstatus=CRYPTO_LIB_SUCCESS;
int8_tIV_VALID=-1;
int8_tARSN_VALID=-1;
// Check for NULL pointersif (arsn==NULL&&sa_ptr->arsn_len>0)
{
returnCRYPTO_LIB_ERR_NULL_ARSN;
}
if (iv==NULL&&sa_ptr->shivf_len>0&&crypto_config->cryptography_type!=CRYPTOGRAPHY_TYPE_KMCCRYPTO)
{
returnCRYPTO_LIB_ERR_NULL_IV;
}
if (sa_ptr==NULL)
{
returnCRYPTO_LIB_ERR_NULL_SA;
}
// rest of Crypto_Check_Ani_Replay() ...
Notice how sa_ptr is derefenced in both of the first two if statements (sa_ptr->arsn_len and sa_ptr->shivf_len). The sa_ptr is checked only after these first two dereferences. Therefore, a null pointer dereference can occur which can cause a crash.
These if statements should be reordered as follows to fix the issue:
int32_tCrypto_Check_Anti_Replay(SecurityAssociation_t*sa_ptr, uint8_t*arsn, uint8_t*iv)
{
int32_tstatus=CRYPTO_LIB_SUCCESS;
int8_tIV_VALID=-1;
int8_tARSN_VALID=-1;
// Check for NULL pointersif (sa_ptr==NULL)
{
returnCRYPTO_LIB_ERR_NULL_SA;
}
if (arsn==NULL&&sa_ptr->arsn_len>0)
{
returnCRYPTO_LIB_ERR_NULL_ARSN;
}
if (iv==NULL&&sa_ptr->shivf_len>0&&crypto_config->cryptography_type!=CRYPTOGRAPHY_TYPE_KMCCRYPTO)
{
returnCRYPTO_LIB_ERR_NULL_IV;
}
// rest of Crypto_Check_Ani_Replay() ...
The text was updated successfully, but these errors were encountered:
spicydll
added a commit
to spicydll/CryptoLib
that referenced
this issue
Jul 2, 2023
I noticed some code that could allow for a null pointer to be dereferenced in
src/src_main/crypto.c
Notice how
sa_ptr
is derefenced in both of the first two if statements (sa_ptr->arsn_len
andsa_ptr->shivf_len
). Thesa_ptr
is checked only after these first two dereferences. Therefore, a null pointer dereference can occur which can cause a crash.These if statements should be reordered as follows to fix the issue:
The text was updated successfully, but these errors were encountered: