Blame SOURCES/unzip-6.0-valgrind.patch

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