From 338c358a75fed510c6e4b0f726c513d3739bb925 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 7 Jan 2020 01:07:56 +0100 Subject: [PATCH] Defensive programming, check bounds of loop variable first Signed-off-by: Joachim Nilsson --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index e6689152..9e95e8f8 100644 --- a/src/util.c +++ b/src/util.c @@ -170,7 +170,7 @@ char *sanitize(char *arg, size_t len) { size_t i = 0; - while (isallowed(arg[i]) && i < len) + while (i < len && isallowed(arg[i])) i++; if (i + 1 < len) {