Commit 5ef01e9b authored by Benjamin Peterson's avatar Benjamin Peterson

merge 3.4 (#23361)

parents 365701ad 22ef9f72
...@@ -13,6 +13,8 @@ Core and Builtins ...@@ -13,6 +13,8 @@ Core and Builtins
Library Library
------- -------
- Issue #23361: Fix possible overflow in Windows subprocess creation code.
- logging.handlers.QueueListener now takes a respect_handler_level keyword - logging.handlers.QueueListener now takes a respect_handler_level keyword
argument which, if set to True, will pass messages to handlers taking handler argument which, if set to True, will pass messages to handlers taking handler
levels into account. levels into account.
......
...@@ -670,13 +670,23 @@ getenvironment(PyObject* environment) ...@@ -670,13 +670,23 @@ getenvironment(PyObject* environment)
"environment can only contain strings"); "environment can only contain strings");
goto error; goto error;
} }
if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH(key) - 1) {
PyErr_SetString(PyExc_OverflowError, "environment too long");
goto error;
}
totalsize += PyUnicode_GET_LENGTH(key) + 1; /* +1 for '=' */ totalsize += PyUnicode_GET_LENGTH(key) + 1; /* +1 for '=' */
if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH(value) - 1) {
PyErr_SetString(PyExc_OverflowError, "environment too long");
goto error;
}
totalsize += PyUnicode_GET_LENGTH(value) + 1; /* +1 for '\0' */ totalsize += PyUnicode_GET_LENGTH(value) + 1; /* +1 for '\0' */
} }
buffer = PyMem_Malloc(totalsize * sizeof(Py_UCS4)); buffer = PyMem_NEW(Py_UCS4, totalsize);
if (! buffer) if (! buffer) {
PyErr_NoMemory();
goto error; goto error;
}
p = buffer; p = buffer;
end = buffer + totalsize; end = buffer + totalsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment