[PATCH xrandr 3/5] Bug #11397: check that numeric --orientation arguments are in range

Aaron Plattner aplattner at nvidia.com
Wed Feb 6 14:38:34 PST 2013


The only valid parameters to -o (--orientation) are 0, 1, 2, 3, normal, left,
inverted, and right.  xrandr converts the strings to numbers and then checks
that they're within range, but doesn't validate them if it was numeric to begin
with.

Move the range check outside of the if statement so that out-of-range numeric
values are rejected properly.

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
---
 xrandr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xrandr.c b/xrandr.c
index 54e0ca8..a9bd9e5 100644
--- a/xrandr.c
+++ b/xrandr.c
@@ -2591,8 +2591,8 @@ main (int argc, char **argv)
 		for (dirind = 0; dirind < 4; dirind++) {
 		    if (strcmp (direction[dirind], argv[i]) == 0) break;
 		}
-		if ((dirind < 0) || (dirind > 3))  usage();
 	    }
+	    if ((dirind < 0) || (dirind > 3))  usage();
 	    rot = dirind;
 	    setit = True;
 	    action_requested = True;
-- 
1.7.12



More information about the xorg-devel mailing list