[PATCH xinput] Fix crash for enable/disable without a device argument

Peter Hutterer peter.hutterer at who-t.net
Sun Nov 24 21:00:36 PST 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/property.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/property.c b/src/property.c
index 66a3842..bf04eeb 100644
--- a/src/property.c
+++ b/src/property.c
@@ -832,12 +832,28 @@ int set_prop(Display *display, int argc, char *argv[], char *name,
 
 int disable(Display *display, int argc, char *argv[], char *name, char *desc)
 {
-    char *new_argv[3] = { argv[0], "Device Enabled", "0" };
+    char *new_argv[3] = { NULL, "Device Enabled", "0" };
+
+    if (argc != 1) {
+        fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
+        return EXIT_FAILURE;
+    }
+
+    new_argv[0] = argv[0];
+
     return set_prop(display, 3, new_argv, name, desc);
 }
 
 int enable(Display *display, int argc, char *argv[], char *name, char *desc)
 {
-    char *new_argv[3] = { argv[0], "Device Enabled", "1" };
+    char *new_argv[3] = { NULL, "Device Enabled", "1" };
+
+    if (argc != 1) {
+        fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
+        return EXIT_FAILURE;
+    }
+
+    new_argv[0] = argv[0];
+
     return set_prop(display, 3, new_argv, name, desc);
 }
-- 
1.8.3.1



More information about the xorg-devel mailing list