Skip to content

Commit 02d8449

Browse files
committed
fix 1. Stack array case (WOLFSSL_SMALL_STACK not defined): buffer is byte buffer[WC_MAX_DIGEST_SIZE] - always valid, never NULL
2. Heap case (WOLFSSL_SMALL_STACK defined): If XMALLOC fails, WC_ALLOC_VAR_EX returns MEMORY_E immediately, so we never reach ForceZero with a NULL pointer
1 parent 0880f9e commit 02d8449

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

wolfcrypt/src/pwdbased.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ int wc_PBKDF2_ex(byte* output, const byte* passwd, int pLen, const byte* salt,
296296
wc_HmacFree(hmac);
297297
}
298298

299-
if (buffer != NULL) {
300-
ForceZero(buffer, (word32)hLen);
301-
}
299+
ForceZero(buffer, (word32)hLen);
302300
WC_FREE_VAR_EX(buffer, heap, DYNAMIC_TYPE_TMP_BUFFER);
303301
WC_FREE_VAR_EX(hmac, heap, DYNAMIC_TYPE_HMAC);
304302

0 commit comments

Comments
 (0)