From 5aaa5cf763af4c0ba627c202b2daa375227d095a Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sat, 23 Apr 2016 11:13:02 +0200 Subject: [PATCH] processes plugin: check boundary first [src/processes.c:1042]: (style) Array index 'name_start_pos' is used before limits check. --- src/processes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/processes.c b/src/processes.c index 5a795b5a..03b44b58 100644 --- a/src/processes.c +++ b/src/processes.c @@ -1038,13 +1038,11 @@ static int ps_read_process (long pid, procstat_t *ps, char *state) * strchr(3) and strrchr(3) to avoid pointer arithmetic which would * otherwise be required to determine name_len. */ name_start_pos = 0; - while ((buffer[name_start_pos] != '(') - && (name_start_pos < buffer_len)) + while (name_start_pos < buffer_len && buffer[name_start_pos] != '(') name_start_pos++; name_end_pos = buffer_len; - while ((buffer[name_end_pos] != ')') - && (name_end_pos > 0)) + while (name_end_pos > 0 && buffer[name_end_pos] != ')') name_end_pos--; /* Either '(' or ')' is not found or they are in the wrong order. -- 2.30.2