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:
parent
157c647eba
commit
e8569f471e
1 changed files with 3 additions and 3 deletions
6
shinyr.c
6
shinyr.c
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue