Fix possible integer overflow and heap corruption in zipimport module

This commit is contained in:
Charalampos Stratakis 2016-06-13 18:40:17 +02:00
parent b4602e4514
commit afe637f988
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,16 @@
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 06abb31..914bf5d 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -1112,6 +1112,11 @@ get_data(PyObject *archive, PyObject *toc_entry)
}
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++;

View File

@ -140,7 +140,7 @@
Summary: Version 3 of the Python programming language aka Python 3000
Name: python3
Version: %{pybasever}.2
Release: 6%{?dist}
Release: 7%{?dist}
License: Python
Group: Development/Languages
@ -730,6 +730,12 @@ Patch202: 00202-fix-undefined-behaviour-in-faulthandler.patch
# openssl requires DH keys to be > 768bits
Patch204: 00204-increase-dh-keys-size.patch
# https://bugs.python.org/issue26171
# https://hg.python.org/cpython/rev/10dad6da1b28/
# Fix possible integer overflow and heap corruption in zipimporter.get_data()
# FIXED UPSTREAM
Patch209: 00209-prevent-buffer-overflow-in-zipimport-module.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora 17 onwards,
@ -1019,6 +1025,8 @@ sed -r -i s/'_PIP_VERSION = "[0-9.]+"'/'_PIP_VERSION = "%{pip_version}"'/ Lib/en
%patch202 -p1
%patch204 -p1
%patch209 -p1
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
# are many differences between 2.6 and the Python 3 library.
#
@ -1908,6 +1916,9 @@ rm -fr %{buildroot}
# ======================================================
%changelog
* Mon Jun 13 2016 Charalampos Stratakis <cstratak@redhat.com> - 3.4.2-6
- Added patch for fixing possible integer overflow and heap corruption in zipimporter.get_data()
* Thu Jul 09 2015 Thomas Spura <tomspur@fedoraproject.org> - 3.4.2-6
- sync with master branch to backport some fixes
- Use 1024bit DH key in test_ssl (Matej Stuchlik)