From 61dc211e0402b7bf309c207c57e87f232e0b805c Mon Sep 17 00:00:00 2001 From: Palle Ravn Date: Sun, 25 Oct 2015 12:49:47 +0100 Subject: [PATCH] Correct index check in ratbag-command When initializing N profiles they are indexed 0 to N-1. However, when setting the active profile to X the validation of X is a check for X > N. Notice that N is invalid as the maximum index is N-1. Change the validation check of the new active profile to X >= N. Signed-off-by: Palle Ravn --- tools/ratbag-command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ratbag-command.c b/tools/ratbag-command.c index 62ace523..a9540317 100644 --- a/tools/ratbag-command.c +++ b/tools/ratbag-command.c @@ -1457,7 +1457,7 @@ ratbag_cmd_profile_active_set(const struct ratbag_cmd *cmd, } num_profiles = ratbag_device_get_num_profiles(device); - if (index > num_profiles) { + if (index >= num_profiles) { error("'%d' is not a valid profile\n", index); goto out; }