diff --git a/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c b/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c index 0eb330e2..82cf94bd 100644 --- a/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +++ b/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c @@ -232,8 +232,9 @@ crypto_hash_sha256_update(crypto_hash_sha256_state *state, in += 64; inlen -= 64; } - memcpy(state->buf, in, inlen); /* inlen < 64 */ - + if (inlen > 0) { + memcpy(state->buf, in, inlen); /* inlen < 64 */ + } return 0; } diff --git a/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c b/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c index 4e6b515c..55af8a0f 100644 --- a/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +++ b/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c @@ -262,8 +262,9 @@ crypto_hash_sha512_update(crypto_hash_sha512_state *state, src += 128; inlen -= 128; } - memcpy(state->buf, src, inlen); /* inlen < 128 */ - + if (inlen > 0) { + memcpy(state->buf, src, inlen); /* inlen < 128 */ + } return 0; }