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
-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
[root@mysql-02 ~]# ll
-rw-r--r-- 1 root root 15248880093 Mar 12 18:34 fulldump.sql
Version-Release number of selected component (if applicable):
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.
The original gzip file is overwritten/removed.
The original gzip file to be untouched.
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).
Created attachment 1002152 [details]
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.