diff options
author | 2020-12-29 13:58:27 +0100 | |
---|---|---|
committer | 2020-12-29 14:58:27 +0200 | |
commit | 0159e5efeebd12b3cf365c8569ca000eac7cb03e (patch) | |
tree | 8f51df34012114bc688b561d2b9c5fc639884600 /Modules | |
parent | bpo-40137: Convert _functools module to use PyType_FromModuleAndSpec. (GH-23405) (diff) | |
download | cpython-0159e5efeebd12b3cf365c8569ca000eac7cb03e.tar.gz cpython-0159e5efeebd12b3cf365c8569ca000eac7cb03e.tar.bz2 cpython-0159e5efeebd12b3cf365c8569ca000eac7cb03e.zip |
bpo-42655: Fix subprocess extra_groups gid conversion (GH-23762)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_posixsubprocess.c | 6 | ||||
-rw-r--r-- | Modules/posixmodule.c | 8 | ||||
-rw-r--r-- | Modules/posixmodule.h | 4 |
3 files changed, 7 insertions, 11 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 46c41d3c20..3b0651620e 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -900,7 +900,7 @@ subprocess_fork_exec(PyObject *module, PyObject *args) if (groups_list != Py_None) { #ifdef HAVE_SETGROUPS Py_ssize_t i; - unsigned long gid; + gid_t gid; if (!PyList_Check(groups_list)) { PyErr_SetString(PyExc_TypeError, @@ -934,10 +934,6 @@ subprocess_fork_exec(PyObject *module, PyObject *args) Py_DECREF(elem); goto cleanup; } else { - /* In posixmodule.c UnsignedLong is used as a fallback value - * if the value provided does not fit in a Long. Since we are - * already doing the bounds checking on the Python side, we - * can go directly to an UnsignedLong here. */ if (!_Py_Gid_Converter(elem, &gid)) { Py_DECREF(elem); PyErr_SetString(PyExc_ValueError, "invalid group id"); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d9eb62f20e..13e3963bf5 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -672,7 +672,7 @@ _PyLong_FromGid(gid_t gid) } int -_Py_Uid_Converter(PyObject *obj, void *p) +_Py_Uid_Converter(PyObject *obj, uid_t *p) { uid_t uid; PyObject *index; @@ -759,7 +759,7 @@ _Py_Uid_Converter(PyObject *obj, void *p) success: Py_DECREF(index); - *(uid_t *)p = uid; + *p = uid; return 1; underflow: @@ -778,7 +778,7 @@ fail: } int -_Py_Gid_Converter(PyObject *obj, void *p) +_Py_Gid_Converter(PyObject *obj, gid_t *p) { gid_t gid; PyObject *index; @@ -866,7 +866,7 @@ _Py_Gid_Converter(PyObject *obj, void *p) success: Py_DECREF(index); - *(gid_t *)p = gid; + *p = gid; return 1; underflow: diff --git a/Modules/posixmodule.h b/Modules/posixmodule.h index 1e00562abc..711ac68693 100644 --- a/Modules/posixmodule.h +++ b/Modules/posixmodule.h @@ -14,8 +14,8 @@ extern "C" { #ifndef MS_WINDOWS PyAPI_FUNC(PyObject *) _PyLong_FromUid(uid_t); PyAPI_FUNC(PyObject *) _PyLong_FromGid(gid_t); -PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, void *); -PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, void *); +PyAPI_FUNC(int) _Py_Uid_Converter(PyObject *, uid_t *); +PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, gid_t *); #endif /* MS_WINDOWS */ #if defined(PYPTHREAD_SIGMASK) || defined(HAVE_SIGWAIT) || \ |