From 5a0087c5321f89ba48c7a5d664a728bec407c06a Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 11 Jun 2024 11:12:48 +0200 Subject: Fix bigint base32 --- source/kit/bigint.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/kit/bigint.h b/source/kit/bigint.h index 0347108..89610f4 100644 --- a/source/kit/bigint.h +++ b/source/kit/bigint.h @@ -480,7 +480,7 @@ static kit_bigint_t kit_bi_from_hex(kit_str_t hex) { return z; } -static u8 KIT_BASE32_DIGITS[] = { +static u8 KIT_BASE32_DIGITS[256] = { ['1'] = 0, ['2'] = 1, ['3'] = 2, ['4'] = 3, ['5'] = 4, ['6'] = 5, ['7'] = 6, ['8'] = 7, ['9'] = 8, ['a'] = 9, ['b'] = 10, ['c'] = 11, ['d'] = 12, ['e'] = 13, ['f'] = 14, @@ -491,12 +491,9 @@ static u8 KIT_BASE32_DIGITS[] = { }; static u8 kit_base32_digit(c8 c) { - assert(c >= '\0' && c < (c8) sizeof KIT_BASE32_DIGITS); assert(c == '1' || KIT_BASE32_DIGITS[(size_t) (u8) c] != 0); - return c >= '\0' && c < (c8) sizeof KIT_BASE32_DIGITS - ? KIT_BASE32_DIGITS[(size_t) (u8) c] - : 0; + return KIT_BASE32_DIGITS[(size_t) (u8) c]; } static kit_bigint_t kit_bi_from_base32(kit_str_t base32) { -- cgit v1.2.3