From 286fb1205f61958079c1e0fb35be68c022009750 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 9 Apr 2026 19:06:11 +0200 Subject: [PATCH] Allow NULL pointers (with length=0) with shorthash --- .../crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c | 2 +- .../crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c b/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c index 5487745b..eb7d4efe 100644 --- a/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c +++ b/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c @@ -15,7 +15,7 @@ crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in, uint64_t k0 = LOAD64_LE(k); uint64_t k1 = LOAD64_LE(k + 8); uint64_t m; - const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t)); + const uint8_t *end = inlen ? in + inlen - (inlen % sizeof(uint64_t)) : in; const int left = inlen & 7; b = ((uint64_t) inlen) << 56; diff --git a/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c b/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c index be984eee..414f7674 100644 --- a/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c +++ b/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c @@ -14,7 +14,7 @@ crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in, uint64_t k0 = LOAD64_LE(k); uint64_t k1 = LOAD64_LE(k + 8); uint64_t m; - const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t)); + const uint8_t *end = inlen ? in + inlen - (inlen % sizeof(uint64_t)) : in; const int left = inlen & 7; b = ((uint64_t) inlen) << 56;