Merge pull request #10795 from kaspar030/fix_sha256_update_with_zero_length

hashes/sha256: don't call memcpy if len==0
This commit is contained in:
Martine Lenders 2019-01-17 11:28:55 +01:00 committed by GitHub
commit b6eb12c6d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,7 +223,9 @@ void sha256_update(sha256_context_t *ctx, const void *data, size_t len)
/* Handle the case where we don't need to perform any transforms */ /* Handle the case where we don't need to perform any transforms */
if (len < 64 - r) { if (len < 64 - r) {
if (len > 0) {
memcpy(&ctx->buf[r], data, len); memcpy(&ctx->buf[r], data, len);
}
return; return;
} }