<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>cve-2014-9636-test-compr-eb</title>
<style type="text/css">
.enscript-comment { font-style: italic; color: rgb(178,34,34); }
.enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
.enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
.enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
.enscript-reference { font-weight: bold; color: rgb(95,158,160); }
.enscript-string { font-weight: bold; color: rgb(188,143,143); }
.enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
.enscript-type { font-weight: bold; color: rgb(34,139,34); }
.enscript-highlight { text-decoration: underline; color: 0; }
</style>
</head>
<body id="top">
<h1 style="margin:8px;" id="f1">cve-2014-9636-test-compr-eb&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="cve-2014-9636-test-compr-eb">plain text</a>]</span></h1>
<hr/>
<div></div>
<pre>
<span class="enscript-reference"><span class="enscript-reference">From:<span class="enscript-comment"><span class="enscript-comment"> mancha &lt;mancha1 AT zoho DOT com&gt;
<span class="enscript-reference"><span class="enscript-reference">Date:<span class="enscript-comment"><span class="enscript-comment"> Mon, 3 Nov 2014
<span class="enscript-reference"><span class="enscript-reference">Subject:<span class="enscript-comment"><span class="enscript-comment"> Info-ZIP UnZip buffer overflow
<span class="enscript-reference"><span class="enscript-reference">Bug-Debian:<span class="enscript-comment"><span class="enscript-comment"> <a href="http://bugs.debian.org/776589">http://bugs.debian.org/776589</a>
</span>
By carefully crafting a corrupt ZIP archive with &quot;extra fields&quot; that
purport to have compressed blocks larger than the corresponding
uncompressed blocks in STORED no-compression mode, an attacker can
trigger a heap overflow that can result in application crash or
possibly have other unspecified impact.

This patch ensures that when extra fields use STORED mode, the
&quot;compressed&quot; and uncompressed block sizes match.

--- a/extract.c
+++ b/extract.c
@@ -2228,6 +2228,7 @@
     ulg eb_ucsize;
     uch *eb_ucptr;
     int r;
+    ush eb_compr_method;
 
     if (compr_offset &lt; 4)                /* field is not compressed: */
         return PK_OK;                    /* do nothing and signal OK */
@@ -2244,6 +2245,14 @@
      ((eb_ucsize &gt; 0L) &amp;&amp; (eb_size &lt;= (compr_offset + EB_CMPRHEADLEN))))
         return IZ_EF_TRUNC;             /* no/bad compressed data! */
 
+    /* 2014-11-03 Michal Zalewski, SMS.
+     * For STORE method, compressed and uncompressed sizes must agree.
+     * <a href="http://www.info-zip.org/phpBB3/viewtopic.php?f=7&amp;t=450">http://www.info-zip.org/phpBB3/viewtopic.php?f=7&amp;t=450</a>
+     */
+    eb_compr_method = makeword( eb + (EB_HEADSIZE + compr_offset));
+    if ((eb_compr_method == STORED) &amp;&amp; (eb_size - compr_offset != eb_ucsize))
+        return PK_ERR;
+
     if (
 #ifdef INT_16BIT
         (((ulg)(extent)eb_ucsize) != eb_ucsize) ||
</pre>
<hr />
</body></html>