master hovercats/oakiss / pkg / unzip / patch / 0025-Fix-bug-in-UZbunzip2-that-incorrectly-updated-G.incn.patch
 1From 705923de022bad2ce0142ccbab68aa57ebe36db1 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 UZbunzip2() that incorrectly updated G.incnt
 5
 6    Fix bug in UZbunzip2() 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    bzip2-compressed file was unzipped. This commit remedies that.
11---
12 extract.c | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/extract.c b/extract.c
16index ad5daac..6712ed0 100644
17--- a/extract.c
18+++ b/extract.c
19@@ -3052,7 +3052,7 @@ __GDEF
20 #endif
21 
22     G.inptr = (uch *)bstrm.next_in;
23-    G.incnt = (G.inbuf + INBUFSIZ) - G.inptr;  /* reset for other routines */
24+    G.incnt -= G.inptr - G.inbuf;       /* reset for other routines */
25 
26 uzbunzip_cleanup_exit:
27     err = BZ2_bzDecompressEnd(&bstrm);
28-- 
292.45.2
30