From 13dfa66514fca15d1fe536f3ba9dda2c817cb03d Mon Sep 17 00:00:00 2001 From: Aaron Voisine Date: Fri, 27 Feb 2015 12:21:24 -0800 Subject: [PATCH] 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 --- base58.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base58.c b/base58.c index 913d581..33566e0 100644 --- a/base58.c +++ b/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)); // Leading zeros, just count - for (i = 0; i < b58sz && !b58digits_map[b58u[i]]; ++i) + for (i = 0; i < b58sz && b58u[i] == '1'; ++i) ++zerocount; for ( ; i < b58sz; ++i)