diff options
| author | Xiuwen Cai <[email protected]> | 2023-12-28 13:17:40 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-28 13:17:40 +0800 |
| commit | 9f3e35d3dcacfac3eed6df8fb8cc6ed9a5a680d5 (patch) | |
| tree | e1e2d7f8fe2149587d3bf02076c99d0f163494d6 | |
| parent | d9ffb0f97dcc97c5dec5675439ea65f3f87b466b (diff) | |
Add check for overflow in queue size calculation in RTOS compatibility layer. (#339)
* Add check for overflow in queue size calculation.
* Update release data and version.
| -rw-r--r-- | utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c index 9882b654..b963f31f 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c +++ b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c @@ -33,6 +33,10 @@ /* start flag, corrected stack */ /* allocation size, */ /* resulting in version 6.1.12 */ +/* 12-31-2023 Xiuwen Cai Modified comment(s), and */ +/* added check for overflow in */ +/* queue size calculation, */ +/* resulting in version 6.4.0 */ /* */ /**************************************************************************/ @@ -1526,6 +1530,13 @@ QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize) } #endif + if ((uxQueueLength > (SIZE_MAX / uxItemSize)) || + (uxQueueLength > (ULONG_MAX / uxItemSize))) { + + /* Integer overflow in queue size */ + return NULL; + } + p_queue = txfr_malloc(sizeof(txfr_queue_t)); if(p_queue == NULL) { return NULL; @@ -2692,6 +2703,13 @@ QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength) } #endif + if ((uxEventQueueLength > (SIZE_MAX / sizeof(void *))) || + (uxEventQueueLength > (ULONG_MAX / sizeof(void *)))) { + + /* Integer overflow in queue size */ + return NULL; + } + p_set = txfr_malloc(sizeof(txfr_queueset_t)); if(p_set == NULL) { return NULL; |
