1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-18 10:32:02 +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; binu = bin;
for (i = 0; i < binsz; ++i) for (i = 0; i < binsz; ++i)
{ {
if (binu[i]) if (binu[i]) {
if (zerocount > i) {
/* result too large */
return false;
}
break; break;
}
--*binszp; --*binszp;
} }
*binszp += zerocount; *binszp += zerocount;