diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-14 18:58:21 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-14 18:58:21 +0200 |
| commit | 1170c2193dbe7bc47b20241732871c043d4e2249 (patch) | |
| tree | c612fa7fc2a4e39ba046eae8afdb717e9eb4f128 /librecrypt_add_algorithm.c | |
| parent | Fix memory leak (diff) | |
| download | librecrypt-1170c2193dbe7bc47b20241732871c043d4e2249.tar.gz librecrypt-1170c2193dbe7bc47b20241732871c043d4e2249.tar.bz2 librecrypt-1170c2193dbe7bc47b20241732871c043d4e2249.tar.xz | |
Fix test bug only found with musl+clang
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_add_algorithm.c | 8 |
1 files 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); |
