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

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