02d1f3
From 5c572555cf5d80309a07c30cf7a54b2501493720 Mon Sep 17 00:00:00 2001
02d1f3
From: Mark Adler <madler@alumni.caltech.edu>
02d1f3
Date: Sun, 9 Feb 2020 21:39:09 -0800
02d1f3
Subject: [PATCH] Fix bug in UZinflate() that incorrectly updated G.incnt.
02d1f3
02d1f3
The update assumed a full buffer, which is not always full. This
02d1f3
could result in a false overlapped element detection when a small
02d1f3
deflate-compressed file was unzipped using an old zlib. This
02d1f3
commit remedies that.
02d1f3
---
02d1f3
 inflate.c | 2 +-
02d1f3
 1 file changed, 1 insertion(+), 1 deletion(-)
02d1f3
02d1f3
diff --git a/inflate.c b/inflate.c
02d1f3
index 2f5a015..70e3cc0 100644
02d1f3
--- a/inflate.c
02d1f3
+++ b/inflate.c
02d1f3
@@ -700,7 +700,7 @@ int UZinflate(__G__ is_defl64)
02d1f3
       G.dstrm.total_out));
02d1f3
 
02d1f3
     G.inptr = (uch *)G.dstrm.next_in;
02d1f3
-    G.incnt = (G.inbuf + INBUFSIZ) - G.inptr;  /* reset for other routines */
02d1f3
+    G.incnt -= G.inptr - G.inbuf;       /* reset for other routines */
02d1f3
 
02d1f3
 uzinflate_cleanup_exit:
02d1f3
     err = inflateReset(&G.dstrm);