fix for potential out-of-bounds memory access
if when counting leading zeros an invalid digit is encountered with it's high-bit set, the index into b58digits_map will be out-of-bounds
This commit is contained in:
2
base58.c
2
base58.c
@@ -52,7 +52,7 @@ bool b58tobin(void *bin, size_t *binszp, const char *b58, size_t b58sz)
|
|||||||
memset(outi, 0, outisz * sizeof(*outi));
|
memset(outi, 0, outisz * sizeof(*outi));
|
||||||
|
|
||||||
// Leading zeros, just count
|
// Leading zeros, just count
|
||||||
for (i = 0; i < b58sz && !b58digits_map[b58u[i]]; ++i)
|
for (i = 0; i < b58sz && b58u[i] == '1'; ++i)
|
||||||
++zerocount;
|
++zerocount;
|
||||||
|
|
||||||
for ( ; i < b58sz; ++i)
|
for ( ; i < b58sz; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user