unit tests: 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 <ronald.cron@arm.com>
diff --git a/tests/suites/host_test.function b/tests/suites/host_test.function
index b7b00ec..aff49ca 100644
--- a/tests/suites/host_test.function
+++ b/tests/suites/host_test.function
@@ -521,8 +521,12 @@
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++;
+ }
}
}