[riot-notifications] [RIOT-OS/RIOT] hashes/sha256: don't call memcpy if len==0 (#10795)

Kaspar Schleiser notifications at github.com
Thu Jan 17 11:13:44 CET 2019

kaspar030 commented on this pull request.

> @@ -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 */
     if (len < 64 - r) {
-        memcpy(&ctx->buf[r], data, len);
+        if (len > 0) {

That changes the semantics.
When len is zero, just return. If ```len < 64 - r```, do the memcpy first.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190117/0638e132/attachment.html>

More information about the notifications mailing list