[Python-checkins] cpython (2.7): prevent buffer overflow in get_data (closes #26171)
benjamin.peterson
python-checkins at python.org
Thu Jan 21 01:25:58 EST 2016
https://hg.python.org/cpython/rev/985fc64c60d6
changeset: 100016:985fc64c60d6
branch: 2.7
parent: 100011:7ec954b9fc54
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
@@ -36,6 +36,9 @@
__str__, __trunc__, and __float__ returning instances of subclasses of
str, long, and float to subclasses of str, long, and float correspondingly.
+- 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
@@ -895,6 +895,11 @@
PyMarshal_ReadShortFromFile(fp); /* local header size */
file_offset += l; /* Start of file data */
+ if (data_size > LONG_MAX - 1) {
+ fclose(fp);
+ PyErr_NoMemory();
+ return NULL;
+ }
raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ?
data_size : data_size + 1);
if (raw_data == NULL) {
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list