Subject: bug#75924: maint: fix s390 buffer flushes

From: Paul Eggert <[email-masked]>
Date: Wed, 29 Jan 2025 10:58:59 -0800

Thanks for the bug report. I installed the attached, a bit simpler than 
the patch you suggested; can you please give it a try?

Also, is there a related bug near dfltcc.c line 375? That is, when 
(inptr == insize && fill_inbuf (1) == EOF && param->cf), won't insize 
then be zero, so that gzip will go into an infinite loop attempting to 
read past EOF?

From 51088970d45baedba4739632305d1dbc5acbb3bf Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 29 Jan 2025 10:52:49 -0800
Subject: [PATCH] gzip: fix problem with s390 buffer flushes

Problem reported by Eduard Stefes <https://bugs.gnu.org/74651>.
* dfltcc.c (dfltcc_deflate): Flush output buffer if premature EOF.
---
 NEWS     | 4 ++++
 dfltcc.c | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 8b8731b..417689c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU gzip NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  'gzip -d' no longer omits the last partial output buffer when the
+  input ends unexpectedly on an IBM Z platform.
+  [bug introduced in gzip-1.11]
+
   'gzip -l' no longer misreports lengths of multimember inputs.
   [bug introduced in gzip-1.12]
 
diff --git a/dfltcc.c b/dfltcc.c
index fcdc05a..c97e19e 100644
--- a/dfltcc.c
+++ b/dfltcc.c
@@ -434,11 +434,7 @@ dfltcc_inflate ()
         flush_outbuf ();
       if (inptr == insize)
         {
-          if (fill_inbuf (1) == EOF)
-            {
-              /* Premature EOF.  */
-              return 2;
-            }
+          fill_inbuf (0);
           inptr = 0;
         }
 
-- 
2.45.2