diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2017-07-16 15:05:21 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2018-02-27 12:18:07 +0100 |
commit | 635a4c8bc9f81852dc77b5dc9de1ce5825849a7f (patch) | |
tree | ad2207f5495adc3a4546f2f1b4de9d6171d156f6 | |
parent | 4e655b2cfc79b02d0ca7cea82b09f1f1133f1a0a (diff) |
xrandr: stricter --scale argument parsing
We used to accept something like --scale 2x3junk as a valid input
(scaling x by 2 and y by 3), even though this isn't really a valid
scaling factor.
Fix by making sure there is nothing after the parsed number(s).
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | xrandr.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3014,11 +3014,12 @@ main (int argc, char **argv) if (!strcmp ("--scale", argv[i])) { double sx, sy; + char junk; if (!config_output) argerr ("%s must be used after --output\n", argv[i]); if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]); - if (sscanf (argv[i], "%lfx%lf", &sx, &sy) != 2) + if (sscanf (argv[i], "%lfx%lf%c", &sx, &sy, &junk) != 2) { - if (sscanf (argv[i], "%lf", &sx) != 1) + if (sscanf (argv[i], "%lf%c", &sx, &junk) != 1) argerr ("failed to parse '%s' as a scaling factor\n", argv[i]); sy = sx; } |