Skip to content

Commit

Permalink
Prevent accidental null dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
torben-hansen committed Dec 9, 2024
1 parent 2ab1f4d commit b669983
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions crypto/fipsmodule/cipher/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,18 +689,32 @@ int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, unsigned key_len) {
return 1;
}

int EVP_CIPHER_nid(const EVP_CIPHER *cipher) { return cipher->nid; }
int EVP_CIPHER_nid(const EVP_CIPHER *cipher) {
if (cipher != NULL) {
return cipher->nid;
}
return 0;
}

unsigned EVP_CIPHER_block_size(const EVP_CIPHER *cipher) {
return cipher->block_size;
size_t EVP_CIPHER_block_size(const EVP_CIPHER *cipher) {
if (cipher != NULL) {
return cipher->block_size;
}
return 0;
}

unsigned EVP_CIPHER_key_length(const EVP_CIPHER *cipher) {
return cipher->key_len;
size_t EVP_CIPHER_key_length(const EVP_CIPHER *cipher) {
if (cipher != NULL) {
return cipher->key_len;
}
return 0;
}

unsigned EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) {
return cipher->iv_len;
size_t EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) {
if (cipher != NULL) {
return cipher->iv_len;
}
return 0;
}

uint32_t EVP_CIPHER_flags(const EVP_CIPHER *cipher) {
Expand Down

0 comments on commit b669983

Please sign in to comment.