uzlib: Upgrade to uzlib v2.9 release
This fixes a large number of crashes on malformed inputs.
This commit is contained in:
parent
1164d5285f
commit
014857b34b
@ -35,6 +35,7 @@
|
||||
|
||||
#if MICROPY_PY_UZLIB
|
||||
|
||||
#define UZLIB_CONF_PARANOID_CHECKS (1)
|
||||
#include "../../lib/uzlib/src/tinf.h"
|
||||
|
||||
#if 0 // print debugging info
|
||||
@ -50,7 +51,7 @@ typedef struct _mp_obj_decompio_t {
|
||||
bool eof;
|
||||
} mp_obj_decompio_t;
|
||||
|
||||
STATIC unsigned char read_src_stream(TINF_DATA *data) {
|
||||
STATIC int read_src_stream(TINF_DATA *data) {
|
||||
byte *p = (void*)data;
|
||||
p -= offsetof(mp_obj_decompio_t, decomp);
|
||||
mp_obj_decompio_t *self = (mp_obj_decompio_t*)p;
|
||||
@ -112,7 +113,7 @@ STATIC mp_uint_t decompio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
|
||||
}
|
||||
|
||||
o->decomp.dest = buf;
|
||||
o->decomp.destSize = size;
|
||||
o->decomp.dest_limit = (unsigned char*)buf+size;
|
||||
int st = uzlib_uncompress_chksum(&o->decomp);
|
||||
if (st == TINF_DONE) {
|
||||
o->eof = true;
|
||||
@ -157,10 +158,10 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
|
||||
byte *dest_buf = m_new(byte, dest_buf_size);
|
||||
|
||||
decomp->dest = dest_buf;
|
||||
decomp->destSize = dest_buf_size;
|
||||
decomp->dest_limit = dest_buf+dest_buf_size;
|
||||
DEBUG_printf("uzlib: Initial out buffer: " UINT_FMT " bytes\n", decomp->destSize);
|
||||
decomp->source = bufinfo.buf;
|
||||
|
||||
decomp->source_limit = (unsigned char *)bufinfo.buf + bufinfo.len;
|
||||
int st;
|
||||
bool is_zlib = true;
|
||||
|
||||
@ -187,7 +188,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
|
||||
dest_buf = m_renew(byte, dest_buf, dest_buf_size, dest_buf_size + 256);
|
||||
dest_buf_size += 256;
|
||||
decomp->dest = dest_buf + offset;
|
||||
decomp->destSize = 256;
|
||||
decomp->dest_limit = dest_buf + offset + 256;
|
||||
}
|
||||
|
||||
mp_uint_t final_sz = decomp->dest - dest_buf;
|
||||
@ -218,6 +219,7 @@ const mp_obj_module_t mp_module_uzlib = {
|
||||
// Source files #include'd here to make sure they're compiled in
|
||||
// only if module is enabled by config setting.
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#include "../../lib/uzlib/src/tinflate.c"
|
||||
#include "../../lib/uzlib/src/tinfzlib.c"
|
||||
#include "../../lib/uzlib/src/tinfgzip.c"
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 27176508e188c0900877e810be34198cd88dcb63
|
||||
Subproject commit f966da0fab121e910ea74f037f074538a2e6dbbb
|
Loading…
Reference in New Issue
Block a user