gh-127165: Disallow embedded NULL characters in _interpreters (#127199)

This commit is contained in:
Peter Bierma 2024-12-01 01:33:23 -05:00 committed by GitHub
parent 328187cc4f
commit 46bfd26fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -342,6 +342,11 @@ _copy_string_obj_raw(PyObject *strobj, Py_ssize_t *p_size)
return NULL;
}
if (size != (Py_ssize_t)strlen(str)) {
PyErr_SetString(PyExc_ValueError, "found embedded NULL character");
return NULL;
}
char *copied = PyMem_RawMalloc(size+1);
if (copied == NULL) {
PyErr_NoMemory();