Last modified: 2014-10-11 13:25:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56105, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54105 - (gifar) gif upload fails with complaint about it being a "corrupt or otherwise unreadable ZIP file."
(gifar)
gif upload fails with complaint about it being a "corrupt or otherwise unread...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
1.21.x
All All
: Low major (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-13 17:41 UTC by clump
Modified: 2014-10-11 13:25 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Specific gif tripping the bad-zip check (1.81 KB, image/gif)
2014-10-11 13:25 UTC, John Mark Vandenberg
Details

Description clump 2013-09-13 17:41:39 UTC
Attempting to upload a specific gif file always fails with the error mentioned in the summary.

Steps to reproduce:

1. Download the image http://images.kingdomofloathing.com/itemimages/snakes/12bl.gif

2. Upload file to mediawiki (versions 1.20.2 and 1.21.1 tried)

Results:

Error displayed: "The file is a corrupt or otherwise unreadable ZIP file. It cannot be properly checked for security."  

Image is not uploaded.  Source filename field reverts to no image selected.

Expected Results:

Image should be uploaded, with no errors given.

Notes:

I don't see anything wrong with the image---it's a regular (small) gif image, and not a zip file.  There are many other gif images on the site, so it is not a problem with gif files in general, it is specific to this particular file.

The message is the textual form of the "zip-bad" error, which is returned by ZipDirectoryReader in a few places.  I turned on debug logging, and found the full failure flow:

-----------
MimeMagic::__construct: loading mime types from /var/www/wiki/includes/mime.types
MimeMagic::__construct: loading mime info from /var/www/wiki/includes/mime.info
MimeMagic::doGuessMimeType: analyzing head and tail of /tmp/phpWYS1lh for magic numbers.
MimeMagic::doGuessMimeType: getimagesize detected /tmp/phpWYS1lh as image/gif
MimeMagic::guessMimeType: guessed mime type of /tmp/phpWYS1lh: image/gif
MimeMagic::improveTypeFromExtension: improved mime type for .gif: image/gif
FSFile::getProps: /tmp/phpWYS1lh loaded, 1851 bytes, image/gif.


mime: <image/gif> extension: <gif>

UploadBase::detectScript: checking for embedded scripts and HTML stuff
UploadBase::detectScript: no scripts found
ZipDirectoryReader: Fatal error: trailing bytes after the end of the file comment
-----------

ZipDirectoryReader's complaint is likely true...but only because it is not a zip file.  Just to be sure I attempted to unzip the file, and only got errors as expected:

-----------
caution:  zipfile comment truncated
warning [12bl.gif]:  zipfile claims to be last disk of a multi-part archive;
  attempting to process anyway, assuming all parts have been concatenated
  together in order.  Expect "errors" and warnings...true multi-part support
  doesn't exist yet (coming soon).
error [12bl.gif]:  missing 6459880350 bytes in zipfile
  (attempting to process anyway)
error [12bl.gif]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
-----------

Loading the image into gimp, doing a dummy-edit and resaving it without a comment or with a different comment does not help.
Comment 1 Bawolff (Brian Wolff) 2013-09-13 19:16:35 UTC
Well the zip program (that you quoted above) is claiming its a multipart zip file.  Its entirely possible to have a file that is both a valid gif file and a valid zip file (so called GIFAR vulnrability). Well I could try checking the gif file in question later to be sure, this does not appear to be a bug at first glance.
Comment 2 clump 2013-09-14 19:42:47 UTC
I do think it's a bug since it is rejecting a perfectly valid image for an invalid reason. 

Seems like this problem has been around for a few years too:

http://lists.wikimedia.org/pipermail/mediawiki-l/2011-December/038423.html

I checked, and the image I am trying to upload also has the magic bye sequence "50 4B 05 06", so that does indeed seem to be the issue. But with arbitrary image data that's bound to happen sometimes!

Since unzip itself chokes on it it must be possible to determine that it not a well formed zip file, and thus not something subject to GIFAR (from my naive reading of the less-than-detailed wikipedia article on GIFAR, it would need a valid zipfile to work properly wouldn't it?)
Comment 3 John Mark Vandenberg 2014-10-11 13:24:32 UTC
Confirmed; reproducible on test.wikipedia.org.

This isnt an exact duplicate of bug 31930, but it very close.  Note that this gif file is 1851 bytes, and doesnt include the java bytecode sequence cafebabe, so I am pretty sure it isnt going to be executed by any JVM.
Comment 4 John Mark Vandenberg 2014-10-11 13:25:21 UTC
Created attachment 16747 [details]
Specific gif tripping the bad-zip check

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links