From e1a05a534aab01167774ac0c0cb1b94f3f395920 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 1 Apr 2020 15:52:06 +0200 Subject: [PATCH] unit tests main: Fix potential buffer overflow Fix potential buffer overflow when tracking the unmet dependencies of a test case. The identifiers of unmet dependencies are stored in an array of fixed size. Ensure that we don't overrun the array. Signed-off-by: Ronald Cron --- tests/suites/host_test.function | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function index 1069c2415..14925ebaf 100644 --- a/tests/suites/host_test.function +++ b/tests/suites/host_test.function @@ -647,8 +647,12 @@ int execute_tests( int argc , const char ** argv ) int dep_id = strtol( params[i], NULL, 10 ); if( dep_check( dep_id ) != DEPENDENCY_SUPPORTED ) { - unmet_dependencies[unmet_dep_count] = dep_id; - unmet_dep_count++; + if( unmet_dep_count < + ARRAY_LENGTH( unmet_dependencies ) ) + { + unmet_dependencies[unmet_dep_count] = dep_id; + unmet_dep_count++; + } } }