mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-74616: Raise ValueError in case of null character in input prompt (GH-1738)
If the input prompt to the builtin input function on terminal has any null character, then raise ValueError instead of silently truncating it. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
8660fb7fd7
commit
4ba15de191
3 changed files with 42 additions and 9 deletions
|
@ -2262,6 +2262,11 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
|||
goto _readline_errors;
|
||||
assert(PyBytes_Check(po));
|
||||
promptstr = PyBytes_AS_STRING(po);
|
||||
if ((Py_ssize_t)strlen(promptstr) != PyBytes_GET_SIZE(po)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"input: prompt string cannot contain null characters");
|
||||
goto _readline_errors;
|
||||
}
|
||||
}
|
||||
else {
|
||||
po = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue