fix: Verify queue set type during usage (#1476)
Verify that a queue set is passed when attempting
to add a queue to the queue set.
diff --git a/queue.c b/queue.c
index 83c7ac7..41ef8ef 100644
--- a/queue.c
+++ b/queue.c
@@ -3225,7 +3225,16 @@
taskENTER_CRITICAL();
{
- if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )
+ if( ( ( Queue_t * ) xQueueSet )->uxItemSize != ( UBaseType_t ) sizeof( Queue_t * ) )
+ {
+ /* The object passed as the queue set is not a queue set. A queue
+ * set always has an item size of sizeof( Queue_t * ). Reject any
+ * other object to prevent a type confusion in which
+ * prvNotifyQueueSetContainer() would later copy uxItemSize bytes
+ * from a single pointer on the stack. */
+ xReturn = pdFAIL;
+ }
+ else if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )
{
/* Cannot add a queue/semaphore to more than one queue set. */
xReturn = pdFAIL;