From c7db2dab7bc803ee84bfec1d8a90e1e608b6cb09 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Thu, 9 Apr 2015 16:30:01 -0700 Subject: afl: xsetwacom: Do not allow negative button numbers Currently its possible to provide a negative (or zero) button number on the commandline, which will be dutifully translated into a negative offset. Detect this and throw an error if encountered. Signed-off-by: Jason Gerecke --- tools/xsetwacom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index e9d455b..96636e2 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1510,7 +1510,7 @@ static void map_actions(Display *dpy, XDevice *dev, param_t* param, int argc, ch if (strcmp(param->prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) { - if (sscanf(argv[0], "%d", &offset) != 1) + if (sscanf(argv[0], "%d", &offset) != 1 || offset <= 0) { fprintf(stderr, "'%s' is not a valid button number.\n", argv[0]); return; @@ -2101,7 +2101,7 @@ static void get_map(Display *dpy, XDevice *dev, param_t *param, int argc, char** if (strcmp(param->prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) { - if (sscanf(argv[0], "%d", &offset) != 1) + if (sscanf(argv[0], "%d", &offset) != 1 || offset <= 0) { fprintf(stderr, "'%s' is not a valid button number.\n", argv[0]); return; -- cgit v1.2.1