churchyard / rpms / python3

Forked from rpms/python3 6 years ago
Clone

Blame 00209-prevent-buffer-overflow-in-zipimport-module.patch

84bfe36
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
84bfe36
index 06abb31..914bf5d 100644
84bfe36
--- a/Modules/zipimport.c
84bfe36
+++ b/Modules/zipimport.c
84bfe36
@@ -1112,6 +1112,11 @@ get_data(PyObject *archive, PyObject *toc_entry)
84bfe36
     }
84bfe36
     file_offset += l;           /* Start of file data */
84bfe36
 
84bfe36
+    if (data_size > LONG_MAX - 1) {
84bfe36
+        fclose(fp);
84bfe36
+        PyErr_NoMemory();
84bfe36
+        return NULL;
84bfe36
+    }
84bfe36
     bytes_size = compress == 0 ? data_size : data_size + 1;
84bfe36
     if (bytes_size == 0)
84bfe36
         bytes_size++;