Blame SOURCES/unzip-6.0-valgrind.patch

623fdc
diff --git a/fileio.c b/fileio.c
623fdc
index ba0a1d0..03fc4be 100644
623fdc
--- a/fileio.c
623fdc
+++ b/fileio.c
623fdc
@@ -2006,6 +2006,7 @@ int do_string(__G__ length, option)   /* return PK-type error code */
623fdc
     unsigned comment_bytes_left;
623fdc
     unsigned int block_len;
623fdc
     int error=PK_OK;
623fdc
+    unsigned int length2;
623fdc
 #ifdef AMIGA
623fdc
     char tmp_fnote[2 * AMIGA_FILENOTELEN];   /* extra room for squozen chars */
623fdc
 #endif
623fdc
@@ -2292,8 +2293,12 @@ int do_string(__G__ length, option)   /* return PK-type error code */
623fdc
             seek_zipf(__G__ G.cur_zipfile_bufstart - G.extra_bytes +
623fdc
                       (G.inptr-G.inbuf) + length);
623fdc
         } else {
623fdc
-            if (readbuf(__G__ (char *)G.extra_field, length) == 0)
623fdc
+            if ((length2 = readbuf(__G__ (char *)G.extra_field, length)) == 0)
623fdc
                 return PK_EOF;
623fdc
+            if(length2 < length) {
623fdc
+              memset (__G__ (char *)G.extra_field+length2, 0 , length-length2);
623fdc
+              length = length2;
623fdc
+            }
623fdc
             /* Looks like here is where extra fields are read */
623fdc
             getZip64Data(__G__ G.extra_field, length);
623fdc
 #ifdef UNICODE_SUPPORT