1de2b3
From 5e2efcd633a4a1fb95a129a75508e7d769e767be Mon Sep 17 00:00:00 2001
1de2b3
From: Mark Adler <madler@alumni.caltech.edu>
1de2b3
Date: Sun, 9 Feb 2020 20:36:28 -0800
1de2b3
Subject: [PATCH] Fix bug in UZbunzip2() that incorrectly updated G.incnt.
1de2b3
1de2b3
The update assumed a full buffer, which is not always full. This
1de2b3
could result in a false overlapped element detection when a small
1de2b3
bzip2-compressed file was unzipped. This commit remedies that.
1de2b3
---
1de2b3
 extract.c | 2 +-
1de2b3
 1 file changed, 1 insertion(+), 1 deletion(-)
1de2b3
1de2b3
diff --git a/extract.c b/extract.c
1de2b3
index d9866f9..0cb7bfc 100644
1de2b3
--- a/extract.c
1de2b3
+++ b/extract.c
1de2b3
@@ -3010,7 +3010,7 @@ __GDEF
1de2b3
 #endif
1de2b3
 
1de2b3
     G.inptr = (uch *)bstrm.next_in;
1de2b3
-    G.incnt = (G.inbuf + INBUFSIZ) - G.inptr;  /* reset for other routines */
1de2b3
+    G.incnt -= G.inptr - G.inbuf;       /* reset for other routines */
1de2b3
 
1de2b3
 uzbunzip_cleanup_exit:
1de2b3
     err = BZ2_bzDecompressEnd(&bstrm);