diff options
author | Peter Bierma <zintensitydev@gmail.com> | 2024-12-01 01:33:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-01 06:33:23 +0000 |
commit | 46bfd26fb294a8769ef6d0c056ee6c9df022a037 (patch) | |
tree | c2294cd17117c17221848ecd8f20e32408b76070 /Python/crossinterp.c | |
parent | 328187cc4fcdd578db42cf6a16c197c3382157a7 (diff) | |
download | cpython-46bfd26fb294a8769ef6d0c056ee6c9df022a037.tar.gz cpython-46bfd26fb294a8769ef6d0c056ee6c9df022a037.zip |
gh-127165: Disallow embedded NULL characters in `_interpreters` (#127199)
Diffstat (limited to 'Python/crossinterp.c')
-rw-r--r-- | Python/crossinterp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/crossinterp.c b/Python/crossinterp.c index 7aaa045f375..0a106ad636b 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -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(); |