kopia lustrzana https://github.com/micropython/micropython
extmod/uzlib: Update to upstream v2.1.
Adds check that LZ offsets fall into the sliding dictionary used. This catches a case when uzlib.DecompIO with a smaller dictionary is used to decompress data which was compressed with a larger dictionary. Previously, this would lead to producing invalid data or crash, now an exception will be thrown.pull/2494/merge
rodzic
6dff3df501
commit
39968aaaff
|
@ -32,6 +32,7 @@ extern "C" {
|
||||||
#define TINF_DONE 1
|
#define TINF_DONE 1
|
||||||
#define TINF_DATA_ERROR (-3)
|
#define TINF_DATA_ERROR (-3)
|
||||||
#define TINF_CHKSUM_ERROR (-4)
|
#define TINF_CHKSUM_ERROR (-4)
|
||||||
|
#define TINF_DICT_ERROR (-5)
|
||||||
|
|
||||||
/* checksum types */
|
/* checksum types */
|
||||||
#define TINF_CHKSUM_NONE 0
|
#define TINF_CHKSUM_NONE 0
|
||||||
|
|
|
@ -361,6 +361,9 @@ static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
|
||||||
/* possibly get more bits from distance code */
|
/* possibly get more bits from distance code */
|
||||||
offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]);
|
offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]);
|
||||||
if (d->dict_ring) {
|
if (d->dict_ring) {
|
||||||
|
if (offs > d->dict_size) {
|
||||||
|
return TINF_DICT_ERROR;
|
||||||
|
}
|
||||||
d->lzOff = d->dict_idx - offs;
|
d->lzOff = d->dict_idx - offs;
|
||||||
if (d->lzOff < 0) {
|
if (d->lzOff < 0) {
|
||||||
d->lzOff += d->dict_size;
|
d->lzOff += d->dict_size;
|
||||||
|
|
Ładowanie…
Reference in New Issue