1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-20 21:38:26 +00:00

fix(core): prevent negative-length array

[no changelog]
This commit is contained in:
Ondřej Vejpustek 2024-04-08 16:50:28 +02:00
parent b1c670090a
commit 548e329f9d

View File

@ -45,6 +45,10 @@ STATIC mp_obj_t mod_trezorcrypto_bech32_decode(size_t n_args,
mp_raise_ValueError(NULL); mp_raise_ValueError(NULL);
} }
if (bech.len < 8) {
mp_raise_ValueError(NULL);
}
uint8_t data[bech.len - 8]; uint8_t data[bech.len - 8];
char hrp[BECH32_MAX_HRP_LEN + 1] = {0}; char hrp[BECH32_MAX_HRP_LEN + 1] = {0};
size_t data_len = 0; size_t data_len = 0;