[Python-checkins] cpython (3.4): prevent buffer overflow in get_data (closes #26171)
benjamin.peterson
python-checkins at python.org
Thu Jan 21 01:26:01 EST 2016
https://hg.python.org/cpython/rev/01ddd608b85c
changeset: 100015:01ddd608b85c
branch: 3.4
parent: 100012:eb19459ce46a
user: Benjamin Peterson <benjamin at python.org>
date: Wed Jan 20 22:23:44 2016 -0800
summary:
prevent buffer overflow in get_data (closes #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
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- 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
@@ -1111,6 +1111,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