[3.12] gh-122431: Disallow negative values in readline.append_history_file (GH-122469) (#127642)

gh-122431: Disallow negative values in `readline.append_history_file` (GH-122469)
(cherry picked from commit 208b0fb645)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2024-12-05 18:15:30 +01:00 committed by GitHub
parent 288d6d04ae
commit a65475fb70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -336,6 +336,12 @@ readline_append_history_file_impl(PyObject *module, int nelements,
PyObject *filename_obj)
/*[clinic end generated code: output=5df06fc9da56e4e4 input=784b774db3a4b7c5]*/
{
if (nelements < 0)
{
PyErr_SetString(PyExc_ValueError, "nelements must be positive");
return NULL;
}
PyObject *filename_bytes;
const char *filename;
int err;