From d21c35a32fe49d145e1df6df0be1af33a0e16669 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 16 Feb 2022 23:55:44 +0100 Subject: Fix previous commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libar2_decode_params.c | 4 +++- test.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libar2_decode_params.c b/libar2_decode_params.c index 1f7d270..86fae6c 100644 --- a/libar2_decode_params.c +++ b/libar2_decode_params.c @@ -8,7 +8,7 @@ decode_u32(const char *s, uint_least32_t *outp) uint_least32_t digit; size_t i; - if ((s[0] == '0' && s[1] != '0') || !isdigit(s[0])) { + if (s[0] == '0' || !isdigit(s[0])) { errno = EINVAL; return 0; } @@ -59,6 +59,8 @@ libar2_decode_params(const char *str, struct libar2_argon2_parameters *params, c goto fail; if (u32 > (uint_least32_t)INT_MAX) goto erange; + if (!u32) + goto einval; params->version = (enum libar2_argon2_version)u32; str += n + 2; if (*str++ != '$') diff --git a/test.c b/test.c index 24f8ba7..c6f5db5 100644 --- a/test.c +++ b/test.c @@ -1135,8 +1135,11 @@ check_failures(void) CHECK("$argon2id$p=128,m=128,t=128$AAAABBBBCCCC$"); CHECK("$argon2id$p=128,t=128,m=128$AAAABBBBCCCC$"); CHECK("$argon2id$m=0128,t=128,p=128$AAAABBBBCCCC$"); + CHECK("$argon2id$m=00128,t=128,p=128$AAAABBBBCCCC$"); CHECK("$argon2id$m=128,t=0128,p=128$AAAABBBBCCCC$"); - CHECK("$argon2id$m=128,t=128,p=0128$AAAABBBBCCCC$"); + CHECK("$argon2id$m=128,t=00128,p=128$AAAABBBBCCCC$"); + CHECK("$argon2id$m=128,t=128,p=0128$AAAABBBBCCCC$");; + CHECK("$argon2id$m=128,t=128,p=00128$AAAABBBBCCCC$"); CHECK("$argon2id$v=0$m=128,t=128,p=128$AAAABBBBCCCC$"); CHECK("$argon2id$v=016$m=128,t=128,p=128$AAAABBBBCCCC$"); errno = 0; -- cgit v1.2.3-70-g09d2