master hovercats/oakiss / pkg / unzip / patch / 0026-Fix-bug-in-UZinflate-that-incorrectly-updated-G.incn.patch
 1From a07b1c0bb82b6dc0f8f224894e49eb9b44a076db Mon Sep 17 00:00:00 2001
 2From: Mark Adler <madler@alumni.caltech.edu>
 3Date: Mon, 28 Apr 2025 12:57:34 -0700
 4Subject: [PATCH] Fix bug in UZinflate() that incorrectly updated G.incnt.
 5
 6    Fix bug in UZinflate() that incorrectly updated G.incnt.
 7
 8    The update assumed a full buffer, which is not always full. This
 9    could result in a false overlapped element detection when a small
10    deflate-compressed file was unzipped using an old zlib. This
11    commit remedies that.
12---
13 inflate.c | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/inflate.c b/inflate.c
17index f2f6864..2c37999 100644
18--- a/inflate.c
19+++ b/inflate.c
20@@ -700,7 +700,7 @@ int UZinflate(__G__ is_defl64)
21       G.dstrm.total_out));
22 
23     G.inptr = (uch *)G.dstrm.next_in;
24-    G.incnt = (G.inbuf + INBUFSIZ) - G.inptr;  /* reset for other routines */
25+    G.incnt -= G.inptr - G.inbuf;       /* reset for other routines */
26 
27 uzinflate_cleanup_exit:
28     err = inflateReset(&G.dstrm);
29-- 
302.45.2
31