mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 23:38:09 +00:00
fix(crypto): Fix undefined behavior in xmr_read_varint().
This commit is contained in:
parent
dab353f888
commit
c5f26beeea
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user