Thanks, I hope I fixed that one by installing the attached.
From 7de030e24744aa848bea0a5ed7d66a1413d8e9f7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 18 Apr 2026 13:40:10 -0700
Subject: [PATCH] gzip: fix diagnostic after failed write
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* gzip.c (main, finish_out): Check ferror after fflush.
That way, if the fflush fails we get a more-precise errno.
If ferror fails, just report EIO regardless of actual error.
(create_outfile): Do not assume a successful sigprocmask
leaves errno alone, when issuing a diagnostic after a failed
write. This fixes an unlikely bug I introduced in commit
a979d9c4db0adbf341eb329abaf3560aa12f10fd dated 2006-12-07.
* util.c (write_err): New function, with most of the old
write_error’s implementation.
(write_error): Use it.
---
gzip.c | 8 +++++++-
gzip.h | 1 +
util.c | 13 ++++++++++---
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/gzip.c b/gzip.c
index b571c42..ec60ad0 100644
--- a/gzip.c
+++ b/gzip.c
@@ -636,6 +636,8 @@ int main (int argc, char **argv)
do_list (-1);
if (fflush (stdout) != 0)
write_error ();
+ if (ferror (stdout))
+ write_err (EIO);
}
if (to_stdout
&& ((synchronous
@@ -1104,7 +1106,7 @@ create_outfile ()
break;
default:
- write_error ();
+ write_err (open_errno);
}
}
@@ -2030,6 +2032,10 @@ do_exit (int exitcode)
static void
finish_out ()
{
+ if (fflush (stdout) < 0)
+ write_error ();
+ if (ferror (stdout))
+ write_err (EIO);
if (fclose (stdout) != 0)
write_error ();
do_exit (OK);
diff --git a/gzip.h b/gzip.h
index bb87fee..326caef 100644
--- a/gzip.h
+++ b/gzip.h
@@ -319,6 +319,7 @@ _Noreturn extern void gzip_error (char const *m);
_Noreturn extern void xalloc_die (void);
extern void warning (char const *m);
_Noreturn extern void read_error (void);
+_Noreturn extern void write_err (int err);
_Noreturn extern void write_error (void);
extern void display_ratio (off_t num, off_t den, FILE *file);
diff --git a/util.c b/util.c
index 9d89f8d..fc521dc 100644
--- a/util.c
+++ b/util.c
@@ -388,14 +388,21 @@ void read_error()
abort_gzip();
}
-void write_error()
+void
+write_err (int err)
{
- int exitcode = errno == EPIPE ? WARNING : ERROR;
+ int exitcode = err == EPIPE ? WARNING : ERROR;
if (! (exitcode == WARNING && quiet))
- fprintf (stderr, "\n%s: %s: %s\n", program_name, ofname, strerror (errno));
+ fprintf (stderr, "\n%s: %s: %s\n", program_name, ofname, strerror (err));
finish_up_gzip (exitcode);
}
+void
+write_error ()
+{
+ write_err (errno);
+}
+
/* ========================================================================
* Display compression ratio on the given stream on 6 characters.
*/
--
2.51.0