]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Enforce valid filemode. Fixes SF Bug #623464.
authorThomas Heller <theller@ctypes.org>
Thu, 7 Nov 2002 16:00:59 +0000 (16:00 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 7 Nov 2002 16:00:59 +0000 (16:00 +0000)
Modules/posixmodule.c

index 0cf00223c22b2c555f20cff392f096b7a080c0d7..9dc1d05d08ed7ed580f7757f8dae36603ef9a5c2 100644 (file)
@@ -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