1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 00:28:10 +00:00

Fix out of bounds read

b58tobin needs to check if there are more leading zeros requested by
the address than there are available
This commit is contained in:
Jochen Hoenicke 2018-03-22 22:06:45 +01:00 committed by Pavol Rusnak
parent 009850f6c9
commit 3d7d99a3e3

View File

@ -114,8 +114,13 @@ bool b58tobin(void *bin, size_t *binszp, const char *b58)
binu = bin;
for (i = 0; i < binsz; ++i)
{
if (binu[i])
if (binu[i]) {
if (zerocount > i) {
/* result too large */
return false;
}
break;
}
--*binszp;
}
*binszp += zerocount;