summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-15 09:22:44 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-15 09:22:44 (GMT)
commit61ec5dca2bf66d43fd196f771b27464e75e8b41a (patch)
tree5cfed0c95be7c57ad3a10e492ff1fd8594e257a8 /Modules/posixmodule.c
parent5fe6de8c72977c794cbc39001ffd21ae7297684a (diff)
downloadcpython-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.c10
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);