diff options
author | Thomas Heller <theller@ctypes.org> | 2002-11-07 16:00:59 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2002-11-07 16:00:59 (GMT) |
commit | 1f043e28f4d8cb4a32da3b07f3719647ba3078b2 (patch) | |
tree | 425a2dd726e948579f3e84d0c9dd951ad1fe567e | |
parent | e3271209e7704d8fc77f4c822e6acde7cd717e54 (diff) | |
download | cpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.zip cpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.tar.gz cpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.tar.bz2 |
Enforce valid filemode. Fixes SF Bug #623464.
-rw-r--r-- | Modules/posixmodule.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 0cf0022..9dc1d05 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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 |