File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ Core and Builtins
1616Library
1717-------
1818
19+ - Issue #23361: Fix possible overflow in Windows subprocess creation code.
20+
1921- Issue #23363: Fix possible overflow in itertools.permutations.
2022
2123- Issue #23364: Fix possible overflow in itertools.product.
Original file line number Diff line number Diff line change @@ -513,13 +513,23 @@ getenvironment(PyObject* environment)
513513 "environment can only contain strings" );
514514 goto error ;
515515 }
516+ if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH (key ) - 1 ) {
517+ PyErr_SetString (PyExc_OverflowError , "environment too long" );
518+ goto error ;
519+ }
516520 totalsize += PyUnicode_GET_LENGTH (key ) + 1 ; /* +1 for '=' */
521+ if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH (value ) - 1 ) {
522+ PyErr_SetString (PyExc_OverflowError , "environment too long" );
523+ goto error ;
524+ }
517525 totalsize += PyUnicode_GET_LENGTH (value ) + 1 ; /* +1 for '\0' */
518526 }
519527
520- buffer = PyMem_Malloc (totalsize * sizeof (Py_UCS4 ));
521- if (! buffer )
528+ buffer = PyMem_NEW (Py_UCS4 , totalsize );
529+ if (! buffer ) {
530+ PyErr_NoMemory ();
522531 goto error ;
532+ }
523533 p = buffer ;
524534 end = buffer + totalsize ;
525535
You can’t perform that action at this time.
0 commit comments