mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Enforce valid filemode. Fixes SF Bug #623464.
This commit is contained in:
parent
e3271209e7
commit
1f043e28f4
1 changed files with 6 additions and 0 deletions
|
|
@ -5048,6 +5048,12 @@ posix_fdopen(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize))
|
||||
return NULL;
|
||||
|
||||
if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"invalid file mode '%s'", mode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
fp = fdopen(fd, mode);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue