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 <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2020-04-01 15:52:06 +02:00
parent 65cc9a2e68
commit e1a05a534a

View file

@ -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++;
}
}
}