70 lines
1.7 KiB
Diff
70 lines
1.7 KiB
Diff
|
From 061417d37f48ca6d77d6a5aacc4faa94be31cf62 Mon Sep 17 00:00:00 2001
|
||
|
From: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
Date: Fri, 5 Oct 2018 08:41:07 +1000
|
||
|
Subject: [PATCH] input: fix ioctl return value handling()
|
||
|
|
||
|
If any of those ioctls fail, the returned data is undefined.
|
||
|
---
|
||
|
evdev/input.c | 17 ++++++++++++++++-
|
||
|
1 file changed, 16 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/evdev/input.c b/evdev/input.c
|
||
|
index b37d3b7..67b9348 100644
|
||
|
--- a/evdev/input.c
|
||
|
+++ b/evdev/input.c
|
||
|
@@ -250,7 +250,10 @@ ioctl_EVIOCGREP(PyObject *self, PyObject *args)
|
||
|
ret = PyArg_ParseTuple(args, "i", &fd);
|
||
|
if (!ret) return NULL;
|
||
|
|
||
|
- ioctl(fd, EVIOCGREP, &rep);
|
||
|
+ ret = ioctl(fd, EVIOCGREP, &rep);
|
||
|
+ if (ret == -1)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
return Py_BuildValue("(ii)", rep[0], rep[1]);
|
||
|
}
|
||
|
|
||
|
@@ -265,6 +268,9 @@ ioctl_EVIOCSREP(PyObject *self, PyObject *args)
|
||
|
if (!ret) return NULL;
|
||
|
|
||
|
ret = ioctl(fd, EVIOCSREP, &rep);
|
||
|
+ if (ret == -1)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
return Py_BuildValue("i", ret);
|
||
|
}
|
||
|
|
||
|
@@ -277,6 +283,9 @@ ioctl_EVIOCGVERSION(PyObject *self, PyObject *args)
|
||
|
if (!ret) return NULL;
|
||
|
|
||
|
ret = ioctl(fd, EVIOCGVERSION, &res);
|
||
|
+ if (ret == -1)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
return Py_BuildValue("i", res);
|
||
|
}
|
||
|
|
||
|
@@ -338,6 +347,9 @@ ioctl_EVIOCG_bits(PyObject *self, PyObject *args)
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
+ if (ret == -1)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
PyObject* res = PyList_New(0);
|
||
|
for (int i=0; i<max; i++) {
|
||
|
if (test_bit(bytes, i)) {
|
||
|
@@ -357,6 +369,9 @@ ioctl_EVIOCGEFFECTS(PyObject *self, PyObject *args)
|
||
|
if (!ret) return NULL;
|
||
|
|
||
|
ret = ioctl(fd, EVIOCGEFFECTS, &res);
|
||
|
+ if (ret == -1)
|
||
|
+ return NULL;
|
||
|
+
|
||
|
return Py_BuildValue("i", res);
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.17.1
|
||
|
|