Skip to content

Commit 6286d74

Browse files
committed
Allow zero length inputs to _wc_Hash_Grow to be a succesful no-op
1 parent 994a1fb commit 6286d74

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

wolfcrypt/src/hash.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,12 @@ int _wc_Hash_Grow(byte** msg, word32* used, word32* len, const byte* in,
19561956
{
19571957
word32 usedSz = 0;
19581958

1959-
if (inSz <= 0 || !WC_SAFE_SUM_WORD32(*used, (word32)inSz, usedSz))
1959+
if (inSz < 0 || !WC_SAFE_SUM_WORD32(*used, (word32)inSz, usedSz))
19601960
return BAD_FUNC_ARG;
19611961

1962+
if (inSz == 0)
1963+
return 0;
1964+
19621965
if (*len < usedSz) {
19631966
if (*msg == NULL) {
19641967
*msg = (byte*)XMALLOC(usedSz, heap, DYNAMIC_TYPE_TMP_BUFFER);

0 commit comments

Comments
 (0)