summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-24 12:54:59 (GMT)
committerGitHub <noreply@github.com>2024-05-24 12:54:59 (GMT)
commit0bab0b3a53da735838720f96f3d3bf86ca6ba125 (patch)
treecd5d0eb10ece68d4fd92e1fbd8755947e98b4873 /Modules
parentc864efba25465eb6a4fff7e0a6df80a9ba449370 (diff)
downloadcpython-0bab0b3a53da735838720f96f3d3bf86ca6ba125.zip
cpython-0bab0b3a53da735838720f96f3d3bf86ca6ba125.tar.gz
cpython-0bab0b3a53da735838720f96f3d3bf86ca6ba125.tar.bz2
[3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) (#119504)
gh-69214: Fix fcntl.ioctl() request type (GH-119498) Use an 'unsigned long' instead of an 'unsigned int' for the request parameter of fcntl.ioctl() to support requests larger than UINT_MAX. (cherry picked from commit 92fab3356f4c61d4c73606e4fae705c6d8f6213b) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/clinic/fcntlmodule.c.h11
-rw-r--r--Modules/fcntlmodule.c6
2 files changed, 9 insertions, 8 deletions
diff --git a/Modules/clinic/fcntlmodule.c.h b/Modules/clinic/fcntlmodule.c.h
index d4846dd..53b139e 100644
--- a/Modules/clinic/fcntlmodule.c.h
+++ b/Modules/clinic/fcntlmodule.c.h
@@ -96,7 +96,7 @@ PyDoc_STRVAR(fcntl_ioctl__doc__,
{"ioctl", (PyCFunction)(void(*)(void))fcntl_ioctl, METH_FASTCALL, fcntl_ioctl__doc__},
static PyObject *
-fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
+fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code,
PyObject *ob_arg, int mutate_arg);
static PyObject *
@@ -104,7 +104,7 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int fd;
- unsigned int code;
+ unsigned long code;
PyObject *ob_arg = NULL;
int mutate_arg = 1;
@@ -120,10 +120,11 @@ fcntl_ioctl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (fd < 0) {
goto exit;
}
- code = (unsigned int)PyLong_AsUnsignedLongMask(args[1]);
- if (code == (unsigned int)-1 && PyErr_Occurred()) {
+ if (!PyLong_Check(args[1])) {
+ PyErr_Format(PyExc_TypeError, "ioctl() argument 2 must be int, not %T", args[1]);
goto exit;
}
+ code = PyLong_AsUnsignedLongMask(args[1]);
if (nargs < 3) {
goto skip_optional;
}
@@ -263,4 +264,4 @@ skip_optional:
exit:
return return_value;
}
-/*[clinic end generated code: output=26793691ab1c75ba input=a9049054013a1b77]*/
+/*[clinic end generated code: output=45a56f53fd17ff3c input=a9049054013a1b77]*/
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index b6eeec2..873bdf2 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -112,7 +112,7 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg)
fcntl.ioctl
fd: fildes
- request as code: unsigned_int(bitwise=True)
+ request as code: unsigned_long(bitwise=True)
arg as ob_arg: object(c_default='NULL') = 0
mutate_flag as mutate_arg: bool = True
/
@@ -148,9 +148,9 @@ code.
[clinic start generated code]*/
static PyObject *
-fcntl_ioctl_impl(PyObject *module, int fd, unsigned int code,
+fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code,
PyObject *ob_arg, int mutate_arg)
-/*[clinic end generated code: output=7f7f5840c65991be input=967b4a4cbeceb0a8]*/
+/*[clinic end generated code: output=3d8eb6828666cea1 input=cee70f6a27311e58]*/
{
#define IOCTL_BUFSZ 1024
/* We use the unsigned non-checked 'I' format for the 'code' parameter