From 13ea0c5d9c3d1e88373af65ee11490077cfb2e80 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 29 Jan 2016 00:37:28 +0200 Subject: [PATCH] Fixed an infinite loop in zipimport caused by cebcd2fd3e1f (issue #19883). --- Modules/zipimport.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 0f68cec85bf5..ee44cab81805 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); -- 2.47.3