summaryrefslogtreecommitdiff
path: root/backport-Fix-bug-when-using-gzflush-with-a-very-small-buffer.patch
blob: 047c17d023fd24e39c6f3225c566b0b095a9142b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
From d98251478246c8ef2f405d76e4ef1678c14d7eda Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Mon, 14 Aug 2023 17:01:54 -0700
Subject: [PATCH] Fix bug when using gzflush() with a very small buffer.

Reference:https://github.com/madler/zlib/commit/d98251478246c8ef2f405d76e4ef1678c14d7eda
Conflict:NA
---
 gzlib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gzlib.c b/gzlib.c
index 2b446c448..29fc4486f 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -308,8 +308,8 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size) {
     /* check and set requested size */
     if ((size << 1) < size)
         return -1;              /* need to be able to double it */
-    if (size < 2)
-        size = 2;               /* need two bytes to check magic header */
+    if (size < 8)
+        size = 8;               /* needed to behave well with flushing */
     state->want = size;
     return 0;
 }