From: Bartosz DziewoƄski Date: Thu, 24 Mar 2016 09:14:03 +0000 (+0100) Subject: ZipDirectoryReader: Don't try to parse zero-length files X-Git-Tag: 1.31.0-rc.0~7527^2 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=a0723d50ffa042dec9e1a8610b22f0d111ac9cd0;p=lhc%2Fweb%2Fwiklou.git ZipDirectoryReader: Don't try to parse zero-length files With the current code, 'zip-bad' would be returned (eventually). I think 'zip-wrong-format' is a more correct response. This prevents weird errors when trying to upload such a file (and results in saner errors instead). Change-Id: Ic2c010f318d98df4783da1cf5126e8dd88aa9014 --- diff --git a/includes/utils/ZipDirectoryReader.php b/includes/utils/ZipDirectoryReader.php index 44815b4750..516e9aec4a 100644 --- a/includes/utils/ZipDirectoryReader.php +++ b/includes/utils/ZipDirectoryReader.php @@ -215,6 +215,10 @@ class ZipDirectoryReader { $startPos = 0; } + if ( $this->getFileLength() === 0 ) { + $this->error( 'zip-wrong-format', "The file is empty." ); + } + $block = $this->getBlock( $startPos ); $sigPos = strrpos( $block, "PK\x05\x06" ); if ( $sigPos === false ) {