Replace sprintf with snprintf (#802)

This change necessitates the introduction of 2 new APIs:

void vTaskListTasks( char * pcWriteBuffer, size_t uxBufferLength );
void vTaskGetRunTimeStatistics( char * pcWriteBuffer, size_t uxBufferLength );

These 2 APIs behave exactly as vTaskList and vTaskGetRunTimeStats
except the fact that they take the length of the pcWriteBuffer as the
second argument to ensure that we do not write past the buffer.

vTaskList and vTaskGetRunTimeStats assume that the length of the
buffer is configSTATS_BUFFER_MAX_LENGTH which defaults to 0xFFFF.
This is done to ensure that the existing applications do not break.
New applications should use the new APIs to avoid memory corruption.
This commit is contained in:
Gaurav-Aggarwal-AWS 2023-09-26 23:07:18 +05:30 committed by GitHub
parent 84bdb05bd2
commit 96d6190b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 328 additions and 64 deletions

View file

@ -2154,20 +2154,20 @@
#define traceRETURN_vTaskExitCriticalFromISR()
#endif
#ifndef traceENTER_vTaskList
#define traceENTER_vTaskList( pcWriteBuffer )
#ifndef traceENTER_vTaskListTasks
#define traceENTER_vTaskListTasks( pcWriteBuffer, uxBufferLength )
#endif
#ifndef traceRETURN_vTaskList
#define traceRETURN_vTaskList()
#ifndef traceRETURN_vTaskListTasks
#define traceRETURN_vTaskListTasks()
#endif
#ifndef traceENTER_vTaskGetRunTimeStats
#define traceENTER_vTaskGetRunTimeStats( pcWriteBuffer )
#ifndef traceENTER_vTaskGetRunTimeStatistics
#define traceENTER_vTaskGetRunTimeStatistics( pcWriteBuffer, uxBufferLength )
#endif
#ifndef traceRETURN_vTaskGetRunTimeStats
#define traceRETURN_vTaskGetRunTimeStats()
#ifndef traceRETURN_vTaskGetRunTimeStatistics
#define traceRETURN_vTaskGetRunTimeStatistics()
#endif
#ifndef traceENTER_uxTaskResetEventItemValue
@ -2686,6 +2686,10 @@
#endif
#endif
#ifndef configSTATS_BUFFER_MAX_LENGTH
#define configSTATS_BUFFER_MAX_LENGTH 0xFFFF
#endif
#ifndef configSTACK_DEPTH_TYPE
/* Defaults to uint16_t for backward compatibility, but can be overridden