memcpy(): pointers must be valid even if the size is 0

This commit is contained in:
Frank Denis 2016-04-12 00:41:37 +02:00
parent 0248c38626
commit 50e11be472
2 changed files with 6 additions and 4 deletions

View File

@ -232,8 +232,9 @@ crypto_hash_sha256_update(crypto_hash_sha256_state *state,
in += 64; in += 64;
inlen -= 64; inlen -= 64;
} }
memcpy(state->buf, in, inlen); /* inlen < 64 */ if (inlen > 0) {
memcpy(state->buf, in, inlen); /* inlen < 64 */
}
return 0; return 0;
} }

View File

@ -262,8 +262,9 @@ crypto_hash_sha512_update(crypto_hash_sha512_state *state,
src += 128; src += 128;
inlen -= 128; inlen -= 128;
} }
memcpy(state->buf, src, inlen); /* inlen < 128 */ if (inlen > 0) {
memcpy(state->buf, src, inlen); /* inlen < 128 */
}
return 0; return 0;
} }