mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix [ 665014 ] files with long lines and an encoding crash.
Ensure that the 'size' arg is correctly passed to the encoding reader to prevent buffer overflows.
This commit is contained in:
parent
6fa0911f5a
commit
a2e303c32d
1 changed files with 2 additions and 1 deletions
|
@ -346,7 +346,8 @@ fp_readl(char *s, int size, struct tok_state *tok)
|
|||
PyObject* utf8;
|
||||
PyObject* buf = tok->decoding_buffer;
|
||||
if (buf == NULL) {
|
||||
PyObject *args = PyTuple_New(0);
|
||||
/* Ask for one less byte so we can terminate it */
|
||||
PyObject *args = Py_BuildValue("(i)", size-1);
|
||||
if (args == NULL)
|
||||
return error_ret(tok);
|
||||
buf = PyObject_Call(tok->decoding_readline, args, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue