libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 78a903946d707cab78c5eb996312deccb3f68c82
parent 866b60aeb94a0fbb751d69802ed16ed09414aa34
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 19 Apr 2019 10:35:35 +0300

sha256_update(): added shortcut for empty data,
avoid wrong/undefined behaviour of memcpy() with null pointer

Diffstat:
Msrc/microhttpd/sha256.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/sha256.c b/src/microhttpd/sha256.c @@ -250,6 +250,9 @@ sha256_update (void *ctx_, mhd_assert((data != NULL) || (length == 0)); + if (0 == length) + return; /* Do nothing */ + /* Note: (count & (SHA256_BLOCK_SIZE-1)) equal (count % SHA256_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned)(ctx->count & (SHA256_BLOCK_SIZE-1));