Windows: improve error handling in SDP parsing
The code in QWinRTBluetoothServiceDiscoveryWorker was using a
Q_ASSERT_SUCCEEDED() macro to verify that COM-API calls succeed. That
is fine when e.g. calling getters of the Windows classes.
However, the part that is reading the binary data from IDataReader
with various ReadX(&value) calls may return actual errors if the buffer
does not have enough bytes to read. This can be a case of a malicious
or broken packet, so we need to handle these cases properly. Otherwise
we will end up populating the service information with garbage data
that comes from uninitialized variables.
For the handling in processServiceSearchResult(), add a new
BREAK_IF_FAILED helper macro, to immediately jump to the next service
if something was wrong with parsing the current one. This is the
pre-existing behavior, because there are already
if (FAILED(hr))
continue;
checks in the code. So, this patch simply extends the error handling.
For the readSequence() method, simply use RETURN_IF_FAILED() macro
to return early from parsing the sequence if there were any read
errors. This is also a pre-existing behavior, because the old code
was doing it e.g. when unknown type was read.
Task-number: QTBUG-145934
Pick-to: 6.11 6.8
Change-Id: Ia4703eb1134bf22f2f46c544429e2ca18d9cad42
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>