aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2024-02-05 00:05:42 +0100
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2024-02-05 00:05:42 +0100
commit5491644e85480586da58e881e6a9bae1c4be947b (patch)
tree2c7aae050a2e63e13ab4cc309ae09ea3087af64d
parentde33d4594ea8b0e933c82c7f9108a43945870f97 (diff)
downloadlibmicrohttpd-5491644e85480586da58e881e6a9bae1c4be947b.tar.gz
libmicrohttpd-5491644e85480586da58e881e6a9bae1c4be947b.zip
Fixed SHA-512/256 calculation for unrealistically large volumes
Fixed loss of one bit when 2 EiB (exabytes) or more processed by a single step after previously processing more then 2 EiB.
-rw-r--r--src/microhttpd/sha512_256.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/microhttpd/sha512_256.c b/src/microhttpd/sha512_256.c
index 1eb6c061..f45883e3 100644
--- a/src/microhttpd/sha512_256.c
+++ b/src/microhttpd/sha512_256.c
@@ -475,6 +475,10 @@ MHD_SHA512_256_update (struct Sha512_256Ctx *ctx,
475 equals (count % SHA512_256_BLOCK_SIZE) for this block size. */ 475 equals (count % SHA512_256_BLOCK_SIZE) for this block size. */
476 bytes_have = (unsigned int) (ctx->count & (SHA512_256_BLOCK_SIZE - 1)); 476 bytes_have = (unsigned int) (ctx->count & (SHA512_256_BLOCK_SIZE - 1));
477 ctx->count += length; 477 ctx->count += length;
478#if SIZEOF_SIZE_T > 7
479 if (length > ctx->count)
480 ctx->count_bits_hi += 1U << 3; /* Value wrap */
481#endif /* SIZEOF_SIZE_T > 7 */
478 count_hi = ctx->count >> 61; 482 count_hi = ctx->count >> 61;
479 if (0 != count_hi) 483 if (0 != count_hi)
480 { 484 {