Skip to content

Commit

Permalink
fix(freertos): Limit idle task name length copy operation
Browse files Browse the repository at this point in the history
This commit limits the idle task name length copy operation to prevent
Out-of-bounds memory access warnings from static code analyzers.

Signed-off-by: Sudeep Mohanty <[email protected]>
  • Loading branch information
sudeep-mohanty committed Dec 6, 2024
1 parent 974351f commit 7eedbf7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3521,11 +3521,16 @@ static BaseType_t prvCreateIdleTasks( void )
{
BaseType_t xReturn = pdPASS;
BaseType_t xCoreID;
char cIdleName[ configMAX_TASK_NAME_LEN ];
char cIdleName[ configMAX_TASK_NAME_LEN ] = { 0 };
TaskFunction_t pxIdleTaskFunction = NULL;
BaseType_t xIdleTaskNameIndex;

for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < ( BaseType_t ) configMAX_TASK_NAME_LEN; xIdleTaskNameIndex++ )
/* The length of the idle task name is limited to the minimum of the length
* of configIDLE_TASK_NAME and configMAX_TASK_NAME_LEN. */
BaseType_t cIdleNameLen = strlen( configIDLE_TASK_NAME );
BaseType_t xCopyLen = ( cIdleNameLen < configMAX_TASK_NAME_LEN ) ? cIdleNameLen : configMAX_TASK_NAME_LEN;

for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < xCopyLen; xIdleTaskNameIndex++ )
{
cIdleName[ xIdleTaskNameIndex ] = configIDLE_TASK_NAME[ xIdleTaskNameIndex ];

Expand Down

0 comments on commit 7eedbf7

Please sign in to comment.