3535
3636#if MICROPY_PY_UZLIB
3737
38+ #define UZLIB_CONF_PARANOID_CHECKS (1)
3839#include "../../lib/uzlib/src/tinf.h"
3940
4041#if 0 // print debugging info
@@ -50,7 +51,7 @@ typedef struct _mp_obj_decompio_t {
5051 bool eof ;
5152} mp_obj_decompio_t ;
5253
53- STATIC unsigned char read_src_stream (TINF_DATA * data ) {
54+ STATIC int read_src_stream (TINF_DATA * data ) {
5455 byte * p = (void * )data ;
5556 p -= offsetof(mp_obj_decompio_t , decomp );
5657 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
112113 }
113114
114115 o -> decomp .dest = buf ;
115- o -> decomp .destSize = size ;
116+ o -> decomp .dest_limit = ( unsigned char * ) buf + size ;
116117 int st = uzlib_uncompress_chksum (& o -> decomp );
117118 if (st == TINF_DONE ) {
118119 o -> eof = true;
@@ -157,10 +158,10 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
157158 byte * dest_buf = m_new (byte , dest_buf_size );
158159
159160 decomp -> dest = dest_buf ;
160- decomp -> destSize = dest_buf_size ;
161+ decomp -> dest_limit = dest_buf + dest_buf_size ;
161162 DEBUG_printf ("uzlib: Initial out buffer: " UINT_FMT " bytes\n" , decomp -> destSize );
162163 decomp -> source = bufinfo .buf ;
163-
164+ decomp -> source_limit = ( unsigned char * ) bufinfo . buf + bufinfo . len ;
164165 int st ;
165166 bool is_zlib = true;
166167
@@ -187,7 +188,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
187188 dest_buf = m_renew (byte , dest_buf , dest_buf_size , dest_buf_size + 256 );
188189 dest_buf_size += 256 ;
189190 decomp -> dest = dest_buf + offset ;
190- decomp -> destSize = 256 ;
191+ decomp -> dest_limit = dest_buf + offset + 256 ;
191192 }
192193
193194 mp_uint_t final_sz = decomp -> dest - dest_buf ;
@@ -218,6 +219,7 @@ const mp_obj_module_t mp_module_uzlib = {
218219// Source files #include'd here to make sure they're compiled in
219220// only if module is enabled by config setting.
220221
222+ #pragma GCC diagnostic ignored "-Wsign-compare"
221223#include "../../lib/uzlib/src/tinflate.c"
222224#include "../../lib/uzlib/src/tinfzlib.c"
223225#include "../../lib/uzlib/src/tinfgzip.c"
0 commit comments