Skip to content

Commit 5b3750c

Browse files
committed
Allow zero length inputs to _wc_Hash_Grow to be a succesful no-op
Added '--enable-all CPPFLAGS=-DWOLFSSL_HASH_KEEP' to the make_check matrix in os-check.yml.
1 parent 994a1fb commit 5b3750c

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.github/workflows/os-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
'--enable-curve25519=nonblock --enable-ecc=nonblock --enable-sp=yes,nonblock CPPFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DEBUG_NONBLOCK"',
9999
'--enable-certreq --enable-certext --enable-certgen --disable-secure-renegotiation-info CPPFLAGS="-DNO_TLS"',
100100
'--enable-ocsp --enable-ocsp-responder --enable-ocspstapling CPPFLAGS="-DWOLFSSL_NONBLOCK_OCSP" --enable-maxfragment',
101+
'--enable-all CPPFLAGS=-DWOLFSSL_HASH_KEEP',
101102
]
102103
name: make check
103104
if: github.repository_owner == 'wolfssl'

wolfcrypt/src/hash.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,14 @@ 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+
/* Allow zero-length input as a no-op. Some callers may pass zero-length
1963+
* data during hash operations and this should not be treated as an error. */
1964+
if (inSz == 0)
1965+
return 0;
1966+
19621967
if (*len < usedSz) {
19631968
if (*msg == NULL) {
19641969
*msg = (byte*)XMALLOC(usedSz, heap, DYNAMIC_TYPE_TMP_BUFFER);

0 commit comments

Comments
 (0)