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>