diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-15 09:22:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-15 09:22:44 (GMT) |
commit | 61ec5dca2bf66d43fd196f771b27464e75e8b41a (patch) | |
tree | 5cfed0c95be7c57ad3a10e492ff1fd8594e257a8 /Modules/posixmodule.c | |
parent | 5fe6de8c72977c794cbc39001ffd21ae7297684a (diff) | |
download | cpython-61ec5dca2bf66d43fd196f771b27464e75e8b41a.zip cpython-61ec5dca2bf66d43fd196f771b27464e75e8b41a.tar.gz cpython-61ec5dca2bf66d43fd196f771b27464e75e8b41a.tar.bz2 |
Issue #9604: posix.initgroups() encodes the username using the fileystem
encoding and surrogateescape error handler. Patch written by David Watson.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index df7cb83..7151289 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4249,13 +4249,19 @@ group id."); static PyObject * posix_initgroups(PyObject *self, PyObject *args) { + PyObject *oname; char *username; + int res; long gid; - if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid)) + if (!PyArg_ParseTuple(args, "O&l:initgroups", + PyUnicode_FSConverter, &oname, &gid)) return NULL; + username = PyBytes_AS_STRING(oname); - if (initgroups(username, (gid_t) gid) == -1) + res = initgroups(username, (gid_t) gid); + Py_DECREF(oname); + if (res == -1) return PyErr_SetFromErrno(PyExc_OSError); Py_INCREF(Py_None); |