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

fix(crypto): Fix undefined behavior in xmr_read_varint().

This commit is contained in:
Andrew Kozlik 2020-12-02 18:20:16 +01:00 committed by Andrew Kozlik
parent dab353f888
commit c5f26beeea

View File

@ -37,7 +37,7 @@ int xmr_read_varint(uint8_t *buff, size_t buff_size, uint64_t *val) {
for (int shift = 0; read < buff_size; shift += 7, ++read) { for (int shift = 0; read < buff_size; shift += 7, ++read) {
uint8_t byte = buff[read]; uint8_t byte = buff[read];
if (byte == 0 && shift != 0) { if ((byte == 0 && shift != 0) || (shift >= 63 && byte > 1)) {
return -1; return -1;
} }