Bug 364071 - assert when reading an unusual but valid Zip file (entry named "/" and bad modes)
Summary: assert when reading an unusual but valid Zip file (entry named "/" and bad mo...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-karchive
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 5.22.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-07 19:31 UTC by Jonathan Marten
Modified: 2016-07-04 18:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Test zip file (384 bytes, application/zip)
2016-06-14 18:48 UTC, Jonathan Marten
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2016-06-07 19:31:40 UTC
I have been sent a Zip archive produced by an unknown program, which has the following listing:

$ zipinfo test.zip 
Archive:  test.zip
Zip file size: 202531733 bytes, number of entries: 2
?rwxr--r--  2.0 unx        0 bl defN 14-Nov-16 18:39 /
?rwxr--r--  2.0 unx 202630033 bl defN 14-Nov-15 22:50 G&M.MP4
2 files, 202630033 bytes uncompressed, 202531511 bytes compressed:  0.0%
$ 

The oddities are the unknown type of the two entries, and the first entry named "/".  Despite these, the zip command-line tools and Ark are able to read this file and view/extract the contents.  Unfortunately trying to view the file in Dolphin, which attempts to enter the archive using the zip ioslave, crashes with the status message "The process for the zip protocol died unexpectedly" and the messages on stderr:

$ dolphin /var/tmp/test.zip
kio_archive(18001)/log_kio_archive ArchiveProtocol::checkNewFile: Need to open a new file
kio_archive(18001)/log_kio_archive ArchiveProtocol::checkNewFile: the full path is "/var/tmp/test.zip/"
kio_archive(18001)/log_kio_archive ArchiveProtocol::checkNewFile: fullPath="/var/tmp/test.zip/" path=""
kio_archive(18001)/log_kio_archive ArchiveProtocol::checkNewFile: Found. archiveFile="/var/tmp/test.zip" path="/"
kio_archive(18001)/log_kio_archive ArchiveProtocol::checkNewFile: Opening KZip on  "/var/tmp/test.zip"
kio_archive(18001)/default qt_assert: ASSERT: "access & S_IFDIR" in file /ws/frameworks/tier1/karchive/src/kzip.cpp, line 702
kioslave: ####### CRASH ###### protocol = tar pid = 18001 signal = 6


Reproducible: Always

Steps to Reproduce:
Open the Zip file in Dolphin or Konqueror.


Actual Results:  
Crash with messages as above.

Expected Results:  
The spurious directory entry should either be handled or ignored.


I can make a similar Zip file (that exhibits the same problem) available if needed, but the smallest example that I have is about 21Mb compressed and the contents are personal.
Comment 1 David Faure 2016-06-14 14:42:34 UTC
Yes it would be very useful to have a small zip file showing the issue, both for debugging and for the unittest.
Comment 2 Jonathan Marten 2016-06-14 18:48:02 UTC
Created attachment 99508 [details]
Test zip file

I've managed to produce a test file by a reproducible method.  The attached file was generated by using the web interface at www.dropbox.com and downloading a complete folder (not individual selected files).  The file is small and contains no personal information.

Archive:  /tmp/test.zip
Zip file size: 384 bytes, number of entries: 2
?rwxr--r--  2.0 unx        0 bl defN 16-Jun-14 17:46 test/
?rwxr--r--  2.0 unx      199 bl defN 16-Jun-14 17:48 test/os-release
2 files, 199 bytes uncompressed, 138 bytes compressed:  30.7%
Comment 3 Sune Vuorela 2016-07-04 18:38:35 UTC
Git commit b7d8fce0a7167f4cea7127c6142ea10c92ff546d by Sune Vuorela.
Committed on 04/07/2016 at 18:36.
Pushed by sune into branch 'master'.

Assume a directory is a directory, even if the permission bit is set wrong

For some historical reasons, we special case zip files claiming to be
created on unix and trust the content a bit more.

Zip files in the wild have shown to violate this, so don't trust them as much.

Thanks to Jonathan Marten for the test case
REVIEW: 128233

A  +-    --    autotests/data/unusual_but_valid_364071.zip
M  +13   -0    autotests/karchivetest.cpp
M  +1    -0    autotests/karchivetest.h
M  +1    -1    src/kzip.cpp

http://commits.kde.org/karchive/b7d8fce0a7167f4cea7127c6142ea10c92ff546d