From: Serhiy Storchaka Date: Thu, 28 Jan 2016 22:37:28 +0000 (+0200) Subject: Fixed an infinite loop in zipimport caused by cebcd2fd3e1f (issue #19883). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13ea0c5d9c3d1e88373af65ee11490077cfb2e80;p=python Fixed an infinite loop in zipimport caused by cebcd2fd3e1f (issue #19883). --- diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 0f68cec85b..ee44cab818 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -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);