summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2002-11-07 16:00:59 (GMT)
committerThomas Heller <theller@ctypes.org>2002-11-07 16:00:59 (GMT)
commit1f043e28f4d8cb4a32da3b07f3719647ba3078b2 (patch)
tree425a2dd726e948579f3e84d0c9dd951ad1fe567e
parente3271209e7704d8fc77f4c822e6acde7cd717e54 (diff)
downloadcpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.zip
cpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.tar.gz
cpython-1f043e28f4d8cb4a32da3b07f3719647ba3078b2.tar.bz2
Enforce valid filemode. Fixes SF Bug #623464.
-rw-r--r--Modules/posixmodule.c6
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