Fix base62 decoder bug

Am stupid. The compiler even warned me there weren’t enough elements
when i wrote this, but i just thought i miscalculated the padding.
This commit is contained in:
Oneric 2025-10-13 00:00:00 +00:00
commit e8569f471e

View file

@ -23,7 +23,7 @@ unsigned char base62_to_dec_table[256] = {
-1, -1, -1, -1, -1, -1,
/* a-z */
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
/* padding */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@ -32,7 +32,7 @@ unsigned char base62_to_dec_table[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
char dec_to_base62_table[62] = {
@ -62,7 +62,7 @@ static bool convert_b62_to_dec(const char* b62, unsigned __int128* res)
*res = 0;
for (; b62 < strend; ++b62) {
unsigned char curr = base62_to_dec_table[(unsigned char) *b62];
if (curr > 62) {
if (curr > 61) {
fprintf(stderr, "Illegal character %c in base62 input!\n", (char) *b62);
return false;
}