From 36c0d81af84b5af3b1ebef95323fd406b68e91de Mon Sep 17 00:00:00 2001 From: Bobby Jap Date: Sat, 26 Aug 2023 18:50:35 -0700 Subject: [PATCH] Fix gzip Decompression Support --- extmod/moduzlib.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index b2f5b5af33..4276c366cd 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -175,13 +175,18 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { decomp->source_limit = (byte *)bufinfo.buf + bufinfo.len; int st; - bool is_zlib = true; + mp_int_t wbits = 0; - if (n_args > 1 && MP_OBJ_SMALL_INT_VALUE(args[1]) < 0) { - is_zlib = false; + if (n_args > 1) { + wbits = MP_OBJ_SMALL_INT_VALUE(args[1]); } - if (is_zlib) { + if (wbits >= 16) { + st = uzlib_gzip_parse_header(decomp); + if (st < 0) { + goto error; + } + } else if (wbits >= 0) { st = uzlib_zlib_parse_header(decomp); if (st < 0) { goto error;