Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 74738) +++ Modules/posixmodule.c (working copy) @@ -1933,14 +1933,26 @@ posix_lchown(PyObject *self, PyObject *args) { char *path = NULL; - int uid, gid; + long uid_arg, gid_arg; + uid_t uid; + gid_t gid; int res; if (!PyArg_ParseTuple(args, "etii:lchown", Py_FileSystemDefaultEncoding, &path, - &uid, &gid)) + &uid_arg, &gid_arg)) return NULL; + uid = uid_arg; + if (uid != uid_arg) { + PyErr_SetString(PyExc_OverflowError, "user id too big"); + return NULL; + } + gid = gid_arg; + if (gid != gid_arg) { + PyErr_SetString(PyExc_OverflowError, "group id too big"); + return NULL; + } Py_BEGIN_ALLOW_THREADS - res = lchown(path, (uid_t) uid, (gid_t) gid); + res = lchown(path, uid, gid); Py_END_ALLOW_THREADS if (res < 0) return posix_error_with_allocated_filename(path);