There's a subtle bug in gzip (1.3.13) decompression when no suffixes are
employed.
The command [gzip -d -S "" <infile>] will, as expected, ask to overwrite the
output file. However, it goes on to unlink the newly
created (decompressed file) resulting in data loss through file deletion.
I believe the attached patch should solve this problem.
Regards
rip
--- gzip.c.orig 2010-02-11 11:34:06.000000000 +0000
+++ gzip.c 2010-02-11 11:37:19.000000000 +0000
@@ -850,7 +850,7 @@
if (!to_stdout)
{
sigset_t oldset;
- int unlink_errno;
+ int unlink_errno = 0;
copy_stat (&istat);
if (close (ofd) != 0)
@@ -858,7 +858,8 @@
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
remove_ofname_fd = -1;
- unlink_errno = xunlink (ifname) == 0 ? 0 : errno;
+ if (z_len != 0)
+ unlink_errno = xunlink (ifname) == 0 ? 0 : errno;
sigprocmask (SIG_SETMASK, &oldset, NULL);
if (unlink_errno)