File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ Core and Builtins
1313Library
1414-------
1515
16+ - Issue #23361: Fix possible overflow in Windows subprocess creation code.
1617
1718What's New in Python 3.4.3rc1?
1819==============================
Original file line number Diff line number Diff line change @@ -535,13 +535,23 @@ getenvironment(PyObject* environment)
535535 "environment can only contain strings" );
536536 goto error ;
537537 }
538+ if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH (key ) - 1 ) {
539+ PyErr_SetString (PyExc_OverflowError , "environment too long" );
540+ goto error ;
541+ }
538542 totalsize += PyUnicode_GET_LENGTH (key ) + 1 ; /* +1 for '=' */
543+ if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH (value ) - 1 ) {
544+ PyErr_SetString (PyExc_OverflowError , "environment too long" );
545+ goto error ;
546+ }
539547 totalsize += PyUnicode_GET_LENGTH (value ) + 1 ; /* +1 for '\0' */
540548 }
541549
542- buffer = PyMem_Malloc (totalsize * sizeof (Py_UCS4 ));
543- if (! buffer )
550+ buffer = PyMem_NEW (Py_UCS4 , totalsize );
551+ if (! buffer ) {
552+ PyErr_NoMemory ();
544553 goto error ;
554+ }
545555 p = buffer ;
546556 end = buffer + totalsize ;
547557
You can’t perform that action at this time.
0 commit comments