busybox unzip fails with empty zip arhcive

walter harms wharms at bfs.de
Tue May 2 16:26:20 UTC 2017



Am 02.05.2017 18:16, schrieb Grant Edwards:
> On 2017-05-02, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>> On Mon, May 1, 2017 at 10:40 PM, Grant Edwards
>> <grant.b.edwards at gmail.com> wrote:
>>> The Busybox 'unzip' utility returns a failure status and prints an
>>> error message when it's given an properly formatted (but empty) zip
>>> archive.
>>>
>>>    $ hexdump -C empty.zip
>>>    00000000  50 4b 05 06 00 00 00 00  00 00 00 00 00 00 00 00  |PK..............|
>>>    00000010  00 00 00 00 00 00                                 |......|
>>>    00000016
>>>
>>>    $ file empty.zip
>>>    empty.zip: Zip archive data (empty)
>>>
>>>    $ busybox unzip empty.zip || echo FAIL
>>>    Archive:  empty.zip
>>>    unzip: invalid zip magic 06054B50
>>>    FAIL
>>>
>>> Why is that an error?
>>
>> Does not happen with current git:
>>
>> $ ./busybox unzip z.zip ; echo $?
>> Archive:  z.zip
>> 0
> 
> Thanks, that's good to know.  I've currently got work-arounds in my
> apps to check the filesize before calling 'unzip'.  Someday, I'll be
> able to take out that code.
> 
>> BTW, the archive is not liked by a "usual" unzip:
>>
>> $ unzip -v
>> UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.
>> ...
>> $ unzip z.zip ; echo $?
>> Archive:  z.zip
>> warning [z.zip]:  zipfile is empty
>> 1
> 
> IMO,thats a bug.  It's a valid zip file (you can even create it
> with info-zip):
> 
>    $ zip -v | head -n4
>    Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
>    This is Zip 3.0 (July 5th 2008), by Info-ZIP.
>    Currently maintained by E. Gordon.  Please send bug reports to
>    the authors using the web page at www.info-zip.org; see README for details.
>    
>    $ cp /dev/null empty
>    
>    $ rm -f empty.zip
>    
>    $ zip empty.zip empty
>      adding: empty (stored 0%)
>    
>    $ zip -d empty.zip empty
>    deleting: empty
>              zip warning: zip file empty
>    
>    $ hexdump -C empty.zip
>    00000000  50 4b 05 06 00 00 00 00  00 00 00 00 00 00 00 00  |PK..............|
>    00000010  00 00 00 00 00 00                                 |......|
> 
> But, since 'zip' is a DOS thing perhaps expectations are different --
> perhaps returning failure when unzipping a valid-but-empty zip file is
> what DOS users expect.
> 

IMHO the most sensible thing to do is reporting to the zip maintainers and ask
for clarification.

re,
 wh


More information about the busybox mailing list