summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2011-03-30 13:54:42 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2011-04-08 11:31:51 +1000
commit19656e837c4bd3711b033992566058be790b5095 (patch)
treea4d22fd7c153d1521a183a4ad75eb1670fd8e0d9 /tools
parent02f5fe64df98c963c865845e79b3a20cfddb62ca (diff)
More explicit input check for set_rotate
Because of how atoi() works, any single non-number (other than the expected cw,ccw,half,none) would be interpreted as being equivlent to 'none'. Since the number of valid arguments is very small, we explicitly check each. Signed-off-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/xsetwacom.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 28b42bc..f92cdd5 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1418,19 +1418,19 @@ static void set_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, cha
TRACE("Rotate '%s' for device %ld.\n", argv[0], dev->device_id);
- if (strcasecmp(argv[0], "cw") == 0)
+ if (strcasecmp(argv[0], "cw") == 0 || strcasecmp(argv[0], "1") == 0)
rotation = 1;
- else if (strcasecmp(argv[0], "ccw") == 0)
+ else if (strcasecmp(argv[0], "ccw") == 0 || strcasecmp(argv[0], "2") == 0)
rotation = 2;
- else if (strcasecmp(argv[0], "half") == 0)
+ else if (strcasecmp(argv[0], "half") == 0 || strcasecmp(argv[0], "3") == 0)
rotation = 3;
- else if (strcasecmp(argv[0], "none") == 0)
+ else if (strcasecmp(argv[0], "none") == 0 || strcasecmp(argv[0], "0") == 0)
rotation = 0;
- else if (strlen(argv[0]) == 1)
+ else
{
- rotation = atoi(argv[0]);
- if (rotation < 0 || rotation > 3)
- goto error;
+ fprintf(stderr, "'%s' is not a valid value for the '%s' property.\n",
+ argv[0], param->name);
+ return;
}
prop = XInternAtom(dpy, param->prop_name, True);