From 50e11be47212c37f6cd7b4de801bfed912bdebac Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 12 Apr 2016 00:41:37 +0200 Subject: [PATCH] memcpy(): pointers must be valid even if the size is 0 --- src/libsodium/crypto_hash/sha256/cp/hash_sha256.c | 5 +++-- src/libsodium/crypto_hash/sha512/cp/hash_sha512.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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; }