Blame SOURCES/00241-CVE-2016-5636-buffer-overflow-in-zipimport-module-fix.patch

ae2451
From 0f12cb75c708978f9201c1dd3464d2a8572b4544 Mon Sep 17 00:00:00 2001
ae2451
From: Charalampos Stratakis <cstratak@redhat.com>
ae2451
Date: Fri, 8 Jul 2016 20:24:10 +0200
ae2451
Subject: [PATCH] CVE-2016-5636 fix
ae2451
ae2451
---
ae2451
 Modules/zipimport.c | 9 +++++++++
ae2451
 1 file changed, 9 insertions(+)
ae2451
ae2451
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
ae2451
index 7240cb4..2e6a61f 100644
ae2451
--- a/Modules/zipimport.c
ae2451
+++ b/Modules/zipimport.c
ae2451
@@ -861,6 +861,10 @@ get_data(char *archive, PyObject *toc_entry)
ae2451
                           &date, &crc)) {
ae2451
         return NULL;
ae2451
     }
ae2451
+    if (data_size < 0) {
ae2451
+        PyErr_Format(ZipImportError, "negative data size");
ae2451
+        return NULL;
ae2451
+    }
ae2451
 
ae2451
     fp = fopen(archive, "rb");
ae2451
     if (!fp) {
ae2451
@@ -895,6 +899,11 @@ get_data(char *archive, PyObject *toc_entry)
ae2451
         PyMarshal_ReadShortFromFile(fp);        /* local header size */
ae2451
     file_offset += l;           /* Start of file data */
ae2451
 
ae2451
+    if (data_size > LONG_MAX - 1) {
ae2451
+        fclose(fp);
ae2451
+        PyErr_NoMemory();
ae2451
+        return NULL;
ae2451
+    }
ae2451
     raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ?
ae2451
                                           data_size : data_size + 1);
ae2451
     if (raw_data == NULL) {
ae2451
-- 
ae2451
2.7.4
ae2451