HciManager::handleHciEventPacket(): check size before accessing the data


The code was unconditionally reinterpter_cast'ing the data to certain
structs without verifying that the read size is large enough.
The EVT_CMD_COMPLETE case had a Q_ASSERT(), but prefer a proper if()
check instead.

This cannot be considered a security issue, because the code is
accessing a buffer that was previously allocated on a stack.
The buffer size is equal to HCI_MAX_EVENT_SIZE, which is large enough
to make sure that the code does not read past the end of the buffer.
We could only get garbage if we actually read less bytes than
expected. The new code generates a warning and returns early in such
case.

Pick-to: 6.9 6.8 6.5
Change-Id: I7d67b2ed0a69753cda95cf7ba827accc132ac593
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commit3a8334197d1b6e5dd996af070a5bce2d5edb6e7f
parent0755ef4c0c36ed8dd384c6c386d0b9fe8f976daf
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeTue, 20 May 2025 13:01:12 +0200