components/unzip/patches/07_CVE-2016-9844.patch
author Lukas Rovensky <Lukas.Rovensky@oracle.com>
Thu, 12 Jan 2017 01:56:35 -0800
changeset 7568 fa3a8a49f433
permissions -rw-r--r--
25208625 problem in UTILITY/ZIP

Patch based on http://seclists.org/oss-sec/2016/q4/600
The community plans to fix this security vulnerability in a future
release, so we will not pass this patch to the community.

--- unzip60/zipinfo.c	2017-01-12 01:09:21.487547363 -0800
+++ unzip60/zipinfo.c.new	2017-01-12 01:13:38.476562067 -0800
@@ -1987,7 +1987,18 @@
         ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
         methbuf[3] = dtype[dnum];
     } else if (methnum >= NUM_METHODS) {   /* unknown */
-        sprintf(&methbuf[1], "%03u", G.crec.compression_method);
+        /* 2016-12-05 SMS. 
+         * https://launchpad.net/bugs/1643750 
+         * Unexpectedly large compression methods overflow 
+         * &methbuf[].  Use the old, three-digit decimal format 
+         * for values which fit.  Otherwise, sacrifice the "u", 
+         * and use four-digit hexadecimal. 
+         */
+         if (G.crec.compression_method <= 999) {
+            sprintf(&methbuf[1], "%03u", G.crec.compression_method);
+         } else {
+            sprintf(&methbuf[0], "%04X", G.crec.compression_method);
+         }
     }
 
     for (k = 0;  k < 15;  ++k)