[Python-checkins] cpython (merge 3.5 -> default): merge 3.5 (#26171)

benjamin.peterson python-checkins at python.org
Thu Jan 21 01:25:58 EST 2016


https://hg.python.org/cpython/rev/2df462852464
changeset:   100018:2df462852464
parent:      100014:e82fb1d2febb
parent:      100017:10dad6da1b28
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Jan 20 22:25:40 2016 -0800
summary:
  merge 3.5 (#26171)

files:
  Misc/NEWS           |  3 +++
  Modules/zipimport.c |  5 +++++
  2 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -140,6 +140,9 @@
   converted to normal strings at run time. Given x=3, then
   f'value={x}' == 'value=3'. Patch by Eric V. Smith.
 
+- Issue #26171: Fix possible integer overflow and heap corruption in
+  zipimporter.get_data().
+
 Library
 -------
 
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -1127,6 +1127,11 @@
     }
     file_offset += l;           /* Start of file data */
 
+    if (data_size > LONG_MAX - 1) {
+        fclose(fp);
+        PyErr_NoMemory();
+        return NULL;
+    }
     bytes_size = compress == 0 ? data_size : data_size + 1;
     if (bytes_size == 0)
         bytes_size++;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list