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