Skip to content

Commit e085d46

Browse files
committed
clear potential null dereference
1 parent 80f971c commit e085d46

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

wolfcrypt/src/evp.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11317,6 +11317,10 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1131711317
unsigned int* s)
1131811318
{
1131911319
enum wc_HashType macType;
11320+
#if defined(WOLFSSL_SHA3) && (defined(WOLFSSL_SHAKE128) || \
11321+
defined(WOLFSSL_SHAKE256))
11322+
unsigned int defaultSz = 0;
11323+
#endif
1132011324

1132111325
WOLFSSL_ENTER("wolfSSL_EVP_DigestFinal");
1132211326

@@ -11345,18 +11349,21 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1134511349

1134611350
case WC_HASH_TYPE_SHAKE128:
1134711351
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE128)
11348-
if (s != NULL)
11349-
*s = 16; /* if mixing up XOF with plain digest 128 bit is
11350-
* default for SHAKE128 */
11352+
if (s == NULL)
11353+
s = &defaultSz;
11354+
*s = 16; /* if mixing up XOF with plain digest 128 bit is
11355+
* default for SHAKE128 */
11356+
1135111357
#else
1135211358
return WOLFSSL_FAILURE;
1135311359
#endif
1135411360
break;
1135511361
case WC_HASH_TYPE_SHAKE256:
1135611362
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_SHAKE256)
11357-
if (s != NULL)
11358-
*s = 32; /* if mixing up XOF with plain digest 256 bit is
11359-
* default for SHAKE256 */
11363+
if (s == NULL)
11364+
s = &defaultSz;
11365+
*s = 32; /* if mixing up XOF with plain digest 256 bit is
11366+
* default for SHAKE256 */
1136011367
#else
1136111368
return WOLFSSL_FAILURE;
1136211369
#endif

0 commit comments

Comments
 (0)