summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorKushal Das <mail@kushaldas.in>2023-12-07 10:22:52 (GMT)
committerGitHub <noreply@github.com>2023-12-07 10:22:52 (GMT)
commit4ba15de19153bb97308996ec85242bdeda358387 (patch)
treed0d59d4ead8ea7e225ea578e4b4f50755c1fee4e /Python
parent8660fb7fd7cdcbfe58ef304f5720efe97ca7c842 (diff)
downloadcpython-4ba15de19153bb97308996ec85242bdeda358387.zip
cpython-4ba15de19153bb97308996ec85242bdeda358387.tar.gz
cpython-4ba15de19153bb97308996ec85242bdeda358387.tar.bz2
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>
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 7a96251..960bca0 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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;