pbzip2: removes input file on decompression failure

Bug #874543 reported by Yavor Nikolov on 2011-10-14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Yavor Nikolov

Bug Description

This was originally reported as Debian bug #638632: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=638632
I'm pasting bug's description below:

How to reproduce:

$ echo TEST | bzip2 >test.bz2
$ (head -c$(($(cat test.bz2|wc -c)-4)) test.bz2 && echo BAD) >bad.bz2
$ ls -l bad*
-rw-r--r-- 1 aaa bbb 45 08-20 13:40 bad.bz2
$ bzip2 -d bad.bz2

bzip2: Data integrity error when decompressing.
        Input file = bad.bz2, output file = bad

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

bzip2: Deleting output file bad, if it exists.
$ ls -l bad*
-rw-r--r-- 1 aaa bbb 45 08-20 13:40 bad.bz2
$ pbzip2 -d bad.bz2
pbzip2: *ERROR: Data integrity (CRC) error in data! Skipping...
$ ls -l bad*
-rw-r--r-- 1 aaa bbb 0 08-20 13:40 bad

Here we can see a valid bzip2 file (test.bz2) is created and then it's last 4 bytes (stream CRC) are clobbered and the resulting bzip2 file with invalid CRC is stored in "bad.bz2".

When pbzip2 attempts to decompress "bad.bz2", it creates an empty output file "bad". Upon exit, the input file "bad.bz2" is removed even though decompression failed. Data stored in "bad.bz2" is lost.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.39-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=pl_PL.utf8, LC_CTYPE=pl_PL.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages pbzip2 depends on:
ii libbz2-1.0 1.0.5-6 high-quality block-sorting file co
ii libc6 2.13-16 Embedded GNU C Library: Shared lib
ii libgcc1 1:4.6.1-7 GCC support library
ii libstdc++6 4.6.1-7 GNU Standard C++ Library v3

Changed in pbzip2:
status: Confirmed → In Progress
Changed in pbzip2:
milestone: none → 1.1.6
status: In Progress → Fix Committed
Changed in pbzip2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers