Bug 1201689 - gzip ignores overwrite prompt input and removes file
Summary: gzip ignores overwrite prompt input and removes file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: gzip
Version: 7.0
Hardware: x86_64
OS: Linux
high
low
Target Milestone: rc
: ---
Assignee: Petr Stodulka
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks: 1191020
TreeView+ depends on / blocked
 
Reported: 2015-03-13 09:33 UTC by Dane
Modified: 2015-07-27 09:29 UTC (History)
3 users (show)

Fixed In Version: gzip-1.5-8.el7
Doc Type: Bug Fix
Doc Text:
Previously, the user's choice of "yes" or "no" in the overwrite prompt was not evaluated correctly, and gzip interpreted both selections as a "yes". Consequently, files were overwritten even when the user did not intend to do so. To fix this bug, duplicate declaration of the yesno() function has been removed, and files are no longer overwritten when "no" is selected.
Clone Of:
Environment:
Last Closed: 2015-07-27 09:29:37 UTC
Target Upstream Version:


Attachments (Terms of Use)
upstream patch (543 bytes, patch)
2015-03-16 08:48 UTC, Petr Stodulka
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1502 0 normal SHIPPED_LIVE gzip bug fix update 2015-07-27 13:29:30 UTC

Description Dane 2015-03-13 09:33:42 UTC
Description of problem:

I had a file 'fulldump.sql.gz' in a directory, and another file which I'd just created 'fulldump.sql'. I wanted to compress fulldump.sql but forgot about the .gz file already existing. gzip prompted me if I wished to overwrite the file or not, I selected no, at which point it appeared to start compressing anyway? 

I CTRL+C'd so I could rename the files and try again, but the original fulldump.sql.gz had been unexpectedly removed.

Backgrounding the compression and examining the directory shows that the original file is overwritten anyway, as the fulldump.sql.gz file size was increasing (from zero), meaning the original file had been overwritten.

Shell session with irrelevant info removed:

[root@mysql-02 ~]# ll -h
total 17G
-rw-r--r--  1 root root  15G Mar 12 18:34 fulldump.sql
-rw-r--r--  1 root root 1.8G Feb 17 09:36 fulldump.sql.gz
[root@zabbix-mysql-02 ~]# gzip fulldump.sql
gzip: fulldump.sql.gz already exists; do you wish to overwrite (y or n)? n
^C
[root@mysql-02 ~]# ll
total 14952528
-rw-r--r--  1 root root 15248880093 Mar 12 18:34 fulldump.sql


Version-Release number of selected component (if applicable):

gzip-1.5-7.el7.x86_64


How reproducible:

Every time.


Steps to Reproduce:

1. dd if=/dev/zero of=./zeros bs=1M count=4096
2.  gzip zeros
3. ls and check that zeros.gz exists
4. dd if=/dev/zero of=./zeros bs=1M count=4096
5. gzip zeros
6. Answer 'no' to the overwrite prompt
7. gzip continues anyway, background gzip to see that the original file is being overwritten.
8. Return gzip to the foreground and CTRL+C before it finishes
9. The original zeros.gz file will be gone.


Actual results:
The original gzip file is overwritten/removed.


Expected results:
The original gzip file to be untouched.


Additional info:
None

Comment 2 Petr Stodulka 2015-03-16 08:47:25 UTC
It is due to duplicit declaration of function yesno() in gzip.h which is in some cases different from original declaration from yesno.h, which is problematic for compilator with "O2" option.

Removed duplicit declaration (upstream solution) and include yesno.h into the gzip.c (upstream solution).

Comment 3 Petr Stodulka 2015-03-16 08:48:08 UTC
Created attachment 1002152 [details]
upstream patch

Comment 8 errata-xmlrpc 2015-07-27 09:29:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1502.html


Note You need to log in before you can comment on or make changes to this bug.