mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +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))
|
if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize))
|
||||||
return NULL;
|
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
|
Py_BEGIN_ALLOW_THREADS
|
||||||
fp = fdopen(fd, mode);
|
fp = fdopen(fd, mode);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue