Browse Source

pubkey: valgrind was reporting about unset memory in address parsing

This is likely due to `libbase58` implicitly relying on the passed in
buffer to be memset to 0, in order to report the correct decoded
length.
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
f10b779c83
  1. 6
      bitcoin/base58.c

6
bitcoin/base58.c

@ -53,12 +53,14 @@ static bool from_base58(u8 *version,
const char *base58, size_t base58_len)
{
u8 buf[1 + sizeof(*rmd) + 4];
/* Avoid memcheck complaining if decoding resulted in a short value */
memset(buf, 0, sizeof(buf));
b58_sha256_impl = my_sha256;
size_t buflen = sizeof(buf);
b58tobin(buf, &buflen, base58, base58_len);
int r = b58check(buf, sizeof(buf), base58, base58_len);
int r = b58check(buf, buflen, base58, base58_len);
*version = buf[0];
memcpy(rmd, buf + 1, sizeof(*rmd));
return r >= 0;

Loading…
Cancel
Save