mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Fix possible integer overflow (#836)
* Fix possible integer overflow --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
59ba98b2e3
commit
4ada1d7d5e
|
@ -112,6 +112,16 @@
|
|||
*/
|
||||
#define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET )
|
||||
|
||||
/**
|
||||
* @brief Max value that fits in a size_t type.
|
||||
*/
|
||||
#define mpuSIZE_MAX ( ~( ( size_t ) 0 ) )
|
||||
|
||||
/**
|
||||
* @brief Check if multiplying a and b will result in overflow.
|
||||
*/
|
||||
#define mpuMULTIPLY_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuSIZE_MAX / ( a ) ) ) )
|
||||
|
||||
/**
|
||||
* @brief Get the index of a free slot in the kernel object pool.
|
||||
*
|
||||
|
@ -1035,10 +1045,12 @@
|
|||
UBaseType_t uxArraySize,
|
||||
configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* PRIVILEGED_FUNCTION */
|
||||
{
|
||||
UBaseType_t uxReturn = pdFALSE;
|
||||
UBaseType_t uxReturn = 0;
|
||||
UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE;
|
||||
UBaseType_t xIsTotalRunTimeWriteable = pdFALSE;
|
||||
|
||||
if( mpuMULTIPLY_WILL_OVERFLOW( sizeof( TaskStatus_t ), uxArraySize ) == 0 )
|
||||
{
|
||||
xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
|
||||
sizeof( TaskStatus_t ) * uxArraySize,
|
||||
tskMPU_WRITE_PERMISSION );
|
||||
|
@ -1055,6 +1067,7 @@
|
|||
{
|
||||
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
|
||||
}
|
||||
}
|
||||
|
||||
return uxReturn;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue