mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'fix/freertos_coverity_oob_idle_task_name' into 'master'
fix(freertos): Limit idle task name length for copy operation See merge request espressif/esp-idf!35872
This commit is contained in:
commit
2c4588bbe6
@ -203,6 +203,7 @@ List of changes made to Vanilla FreeRTOS V10.5.1 header files to allow for build
|
|||||||
### tasks.c
|
### tasks.c
|
||||||
|
|
||||||
- Backported a change where the IDLE tasks are created with the core ID as a suffix in the task name.
|
- Backported a change where the IDLE tasks are created with the core ID as a suffix in the task name.
|
||||||
|
- Backported a change where the IDLE task name copy length is restricted to avoid out-of-bounds copy errors.
|
||||||
|
|
||||||
### timers.c
|
### timers.c
|
||||||
|
|
||||||
|
@ -2254,7 +2254,21 @@ static BaseType_t prvCreateIdleTasks( void )
|
|||||||
BaseType_t xCoreID;
|
BaseType_t xCoreID;
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
#if ( configNUMBER_OF_CORES > 1 )
|
||||||
char cIdleName[ configMAX_TASK_NAME_LEN ];
|
|
||||||
|
/* The code for limiting the idle task name copy length has been backported from the upstream
|
||||||
|
* FreeRTOS-Kernel source. The reference for the same is on the mainline
|
||||||
|
* at the commit id# f31787d35d5614620fc6fefa6c12df2583612fcf. */
|
||||||
|
char cIdleName[ configMAX_TASK_NAME_LEN ] = { 0 };
|
||||||
|
BaseType_t xIdleNameLen;
|
||||||
|
BaseType_t xCopyLen;
|
||||||
|
|
||||||
|
configASSERT( ( configIDLE_TASK_NAME != NULL ) && ( configMAX_TASK_NAME_LEN > 3 ) );
|
||||||
|
|
||||||
|
/* The length of the idle task name is limited to the minimum of the length
|
||||||
|
* of configIDLE_TASK_NAME and configMAX_TASK_NAME_LEN - 2, keeping space
|
||||||
|
* for the core ID suffix and the null-terminator. */
|
||||||
|
xIdleNameLen = strlen( configIDLE_TASK_NAME );
|
||||||
|
xCopyLen = xIdleNameLen < ( configMAX_TASK_NAME_LEN - 2 ) ? xIdleNameLen : ( configMAX_TASK_NAME_LEN - 2 );
|
||||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||||
|
|
||||||
/* Add each idle task at the lowest priority. */
|
/* Add each idle task at the lowest priority. */
|
||||||
@ -2262,7 +2276,7 @@ static BaseType_t prvCreateIdleTasks( void )
|
|||||||
{
|
{
|
||||||
#if ( configNUMBER_OF_CORES > 1 )
|
#if ( configNUMBER_OF_CORES > 1 )
|
||||||
{
|
{
|
||||||
BaseType_t x;
|
BaseType_t xIdleTaskNameIndex;
|
||||||
|
|
||||||
if( xReturn == pdFAIL )
|
if( xReturn == pdFAIL )
|
||||||
{
|
{
|
||||||
@ -2275,43 +2289,14 @@ static BaseType_t prvCreateIdleTasks( void )
|
|||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
for( x = ( BaseType_t ) 0; x < ( BaseType_t ) configMAX_TASK_NAME_LEN; x++ )
|
for( xIdleTaskNameIndex = ( BaseType_t ) 0; xIdleTaskNameIndex < xCopyLen; xIdleTaskNameIndex++ )
|
||||||
{
|
{
|
||||||
cIdleName[ x ] = configIDLE_TASK_NAME[ x ];
|
cIdleName[ xIdleTaskNameIndex ] = configIDLE_TASK_NAME[ xIdleTaskNameIndex ];
|
||||||
|
|
||||||
/* Don't copy all configMAX_TASK_NAME_LEN if the string is shorter than
|
|
||||||
* configMAX_TASK_NAME_LEN characters just in case the memory after the
|
|
||||||
* string is not accessible (extremely unlikely). */
|
|
||||||
if( cIdleName[ x ] == ( char ) 0x00 )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append the idle task number to the end of the name if there is space. */
|
/* Append the idle task number to the end of the name. */
|
||||||
if( x < ( BaseType_t ) configMAX_TASK_NAME_LEN )
|
cIdleName[ xIdleTaskNameIndex ] = ( char ) ( xCoreID + '0' );
|
||||||
{
|
cIdleName[ xIdleTaskNameIndex + 1 ] = '\0';
|
||||||
cIdleName[ x ] = ( char ) ( xCoreID + '0' );
|
|
||||||
x++;
|
|
||||||
|
|
||||||
/* And append a null character if there is space. */
|
|
||||||
if( x < ( BaseType_t ) configMAX_TASK_NAME_LEN )
|
|
||||||
{
|
|
||||||
cIdleName[ x ] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user