[BusyBox] bug#1265: patch which fixes the gunzip hang problem

Matthias Lang matthias at corelatus.se
Fri Aug 16 02:46:04 UTC 2002


Hi,

A simple way to test this bug is to test gunzip on all possible
truncations of a correct .gz file:

   > ls -l good.gz
   -rw-rw-r--    1 matthias matthias      894 Aug 16 09:54 good.gz

   for i in 0 1 2 3 4 5 6 7 8; do for j in 0 1 2 3 4 5 6 7 8 9; do for k in 0 1 2 3 4 5 6 7 8 9; do dd if=good.gz of=trunc.gz bs=1 count=$i$j$k; ./busybox gunzip -c trunc.gz > /dev/null; done; done;done

busybox 0.60.3 hangs on the majority of such truncated files. 

I modified unzip.c to check the return value of fgetc() in all cases
except those where it was obvious that an ignored EOF couldn't result
in a hang. The patch doesn't seem to make things larger or slower:

          0.60.3          patched
----------------------------------------------------------------------
Size:     191944          191944     (compiled out of the box for x86)
Speed:    2.6s            2.5s       (user + sys, on a 1M gzipped file)

Matt
---
http://www.corelatus.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gunzip_hang_fix.gz
Type: application/octet-stream
Size: 1644 bytes
Desc: patch to prevent gunzip from hanging on corrupt files
Url : http://lists.busybox.net/pipermail/busybox/attachments/20020816/f85b8137/attachment.obj 


More information about the busybox mailing list