Blame SOURCES/unzip-6.0-overflow-long-fsize.patch

7e0a4d
diff --git a/list.c b/list.c
7e0a4d
index f7359c3..4c3d703 100644
7e0a4d
--- a/list.c
7e0a4d
+++ b/list.c
7e0a4d
@@ -97,7 +97,7 @@ int list_files(__G)    /* return PK-type error code */
7e0a4d
 {
7e0a4d
     int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
7e0a4d
 #ifndef WINDLL
7e0a4d
-    char sgn, cfactorstr[10];
7e0a4d
+    char sgn, cfactorstr[13];
7e0a4d
     int longhdr=(uO.vflag>1);
7e0a4d
 #endif
7e0a4d
     int date_format;
7e0a4d
@@ -339,7 +339,19 @@ int list_files(__G)    /* return PK-type error code */
7e0a4d
                 G.crec.compression_method == ENHDEFLATED) {
7e0a4d
                 methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
7e0a4d
             } else if (methnum >= NUM_METHODS) {
7e0a4d
-                sprintf(&methbuf[4], "%03u", G.crec.compression_method);
7e0a4d
+                /* 2013-02-26 SMS.
7e0a4d
+                 * http://sourceforge.net/tracker/?func=detail
7e0a4d
+                 *  &aid=2861648&group_id=118012&atid=679786
7e0a4d
+                 * Unexpectedly large compression methods overflow
7e0a4d
+                 * &methbuf[].  Use the old, three-digit decimal format
7e0a4d
+                 * for values which fit.  Otherwise, sacrifice the
7e0a4d
+                 * colon, and use four-digit hexadecimal.
7e0a4d
+                 */
7e0a4d
+                if (G.crec.compression_method <= 999) {
7e0a4d
+                    sprintf( &methbuf[ 4], "%03u", G.crec.compression_method);
7e0a4d
+                } else {
7e0a4d
+                    sprintf( &methbuf[ 3], "%04X", G.crec.compression_method);
7e0a4d
+                }
7e0a4d
             }
7e0a4d
 
7e0a4d
 #if 0       /* GRR/Euro:  add this? */