Skip to content

Commit 50bd5de

Browse files
committed
prevent buffer overflow in get_data (closes #26171)
1 parent 20fdd15 commit 50bd5de

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: tba
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #26171: Fix possible integer overflow and heap corruption in
14+
zipimporter.get_data().
15+
1316
Library
1417
-------
1518

Modules/zipimport.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,11 @@ get_data(PyObject *archive, PyObject *toc_entry)
11111111
}
11121112
file_offset += l; /* Start of file data */
11131113

1114+
if (data_size > LONG_MAX - 1) {
1115+
fclose(fp);
1116+
PyErr_NoMemory();
1117+
return NULL;
1118+
}
11141119
bytes_size = compress == 0 ? data_size : data_size + 1;
11151120
if (bytes_size == 0)
11161121
bytes_size++;

0 commit comments

Comments
 (0)