From 1170c2193dbe7bc47b20241732871c043d4e2249 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 14 May 2026 18:58:21 +0200 Subject: Fix test bug only found with musl+clang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_add_algorithm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/librecrypt_add_algorithm.c b/librecrypt_add_algorithm.c index d7e2700..dfcc08e 100644 --- a/librecrypt_add_algorithm.c +++ b/librecrypt_add_algorithm.c @@ -176,6 +176,7 @@ main(void) size_t i, min, phraselen; int strict_pad; const void *lut; + size_t n; ssize_t r; SET_UP_ALARM(); @@ -283,10 +284,11 @@ main(void) phraselen = (size_t)r; stpcpy(expected, "$argon2d$m=8,t=1,p=1$"SALT1"$"ASTRA">$argon2i$m=8,t=4,p=1$"SALT2"$"); - r = librecrypt_hash(&expected[strlen(expected)], sizeof(expected) - strlen(expected), + n = strlen(expected); + r = librecrypt_hash(&expected[n], sizeof(expected) - n, phrase, phraselen, "$argon2i$m=8,t=4,p=1$"SALT2"$*32", NULL); - assert(r > 0 && (size_t)r < sizeof(expected) - strlen(expected)); - assert(!expected[strlen(expected) + (size_t)r]); + assert(r > 0 && (size_t)r < sizeof(expected) - n); + assert(!expected[n + (size_t)r]); CHECK("$argon2d$m=8,t=1,p=1$"SALT1"$"HASH1, "$argon2i$m=8,t=4,p=1$"SALT2"$*32", expected); CHECK("$argon2d$m=8,t=1,p=1$"SALT1"$"HASH1, "$argon2i$m=8,t=4,p=1$"SALT2"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", expected); -- cgit v1.2.3-70-g09d2