mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Bug #869197: setgroups rejects long integer argument
This commit is contained in:
parent
f96f5f5bbe
commit
a13c2446dc
2 changed files with 33 additions and 6 deletions
|
@ -181,6 +181,8 @@ Core and builtins
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Bug #869197: os.setgroups rejects long integer arguments
|
||||||
|
|
||||||
- Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint
|
- Bug #1346533, select.poll() doesn't raise an error if timeout > sys.maxint
|
||||||
|
|
||||||
- Bug #1344508, Fix UNIX mmap leaking file descriptors
|
- Bug #1344508, Fix UNIX mmap leaking file descriptors
|
||||||
|
|
|
@ -4912,13 +4912,38 @@ posix_setgroups(PyObject *self, PyObject *args)
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!PyInt_Check(elem)) {
|
if (!PyInt_Check(elem)) {
|
||||||
|
if (!PyLong_Check(elem)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"groups must be integers");
|
"groups must be integers");
|
||||||
Py_DECREF(elem);
|
Py_DECREF(elem);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
} else {
|
||||||
|
unsigned long x = PyLong_AsUnsignedLong(elem);
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"group id too big");
|
||||||
|
Py_DECREF(elem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
grouplist[i] = x;
|
||||||
|
/* read back the value to see if it fitted in gid_t */
|
||||||
|
if (grouplist[i] != x) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"group id too big");
|
||||||
|
Py_DECREF(elem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long x = PyInt_AsLong(elem);
|
||||||
|
grouplist[i] = x;
|
||||||
|
if (grouplist[i] != x) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"group id too big");
|
||||||
|
Py_DECREF(elem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* XXX: check that value fits into gid_t. */
|
|
||||||
grouplist[i] = PyInt_AsLong(elem);
|
|
||||||
Py_DECREF(elem);
|
Py_DECREF(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue