commit d75b4088b08f12aea8079aad55996a65b7b312c8 from: Stefan Sperling date: Tue Feb 08 10:52:17 2022 UTC set zlib output buffer length properly after resizing the output buffer ok millert naddy commit - a9bd296d051d3edccf7eb07517d89eaa47ddb872 commit + d75b4088b08f12aea8079aad55996a65b7b312c8 blob - 83651a59bfd0bb7010ea28f96ca5569af7be698d blob + ca950e73ef86eb0cf17cef593f6caec9e40a2dcb --- lib/inflate.c +++ lib/inflate.c @@ -325,7 +325,6 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, if (zb.flags & GOT_INFLATE_F_HAVE_MORE) { if (outbuf == NULL) continue; - zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; newbuf = reallocarray(*outbuf, ++nbuf, GOT_INFLATE_BUFSIZE); if (newbuf == NULL) { @@ -337,6 +336,7 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, } *outbuf = newbuf; zb.outbuf = newbuf + *outlen; + zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; } } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); @@ -385,7 +385,6 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen if (zb.flags & GOT_INFLATE_F_HAVE_MORE) { if (outbuf == NULL) continue; - zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; newbuf = reallocarray(*outbuf, ++nbuf, GOT_INFLATE_BUFSIZE); if (newbuf == NULL) { @@ -397,6 +396,7 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen } *outbuf = newbuf; zb.outbuf = newbuf + *outlen; + zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; } } while (zb.flags & GOT_INFLATE_F_HAVE_MORE);