aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python/CVE-2016-5636.patch
blob: 5906153d31da5252d3438dc2584589ce11bfb053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# HG changeset patch
# User Benjamin Peterson <benjamin@python.org>
# Date 1453357424 28800
# Node ID 985fc64c60d6adffd1138b6cc46df388ca91ca5d
# Parent  7ec954b9fc54448a35b56d271340ba109eb381b9
prevent buffer overflow in get_data (closes #26171)

Upstream-Status: Backport
CVE: CVE-2016-5636
Signed-off-by: Armin Kuster <akuster@mvista.com>

Index: Python-2.7.9/Misc/NEWS
===================================================================
--- Python-2.7.9.orig/Misc/NEWS
+++ Python-2.7.9/Misc/NEWS
@@ -7,6 +7,9 @@ What's New in Python 2.7.9?
 
 *Release date: 2014-12-10*
 
+- Issue #26171: Fix possible integer overflow and heap corruption in
+  zipimporter.get_data().
+
 Library
 -------
 
Index: Python-2.7.9/Modules/zipimport.c
===================================================================
--- Python-2.7.9.orig/Modules/zipimport.c
+++ Python-2.7.9/Modules/zipimport.c
@@ -895,6 +895,11 @@ get_data(char *archive, PyObject *toc_en
         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) {