]> granicus.if.org Git - python/commitdiff
Fixed an infinite loop in zipimport caused by cebcd2fd3e1f (issue #19883).
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 28 Jan 2016 22:37:28 +0000 (00:37 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 28 Jan 2016 22:37:28 +0000 (00:37 +0200)
Modules/zipimport.c

index 0f68cec85bf506aeacc931b5308b23a628d93046..ee44cab818059b4a0645dfb157f676fc64afaef1 100644 (file)
@@ -776,14 +776,14 @@ read_directory(const char *archive)
 
     /* Start of Central Directory */
     count = 0;
+    if (fseek(fp, (long)header_position, 0) == -1) {
+        goto file_error;
+    }
     for (;;) {
         PyObject *t;
         size_t n;
         int err;
 
-        if (fseek(fp, (long)header_position, 0) == -1) {
-            goto file_error;
-        }
         n = fread(buffer, 1, 46, fp);
         if (n < 4) {
             goto eof_error;
@@ -837,7 +837,6 @@ read_directory(const char *archive)
                 goto file_error;
             }
         }
-        header_offset += header_size;
 
         strncpy(path + length + 1, name, MAXPATHLEN - length - 1);