Android scan record parsing: fix length and type extraction


The scanRecordBuffer is an array of chars. In the scan record format,
the length of the entry is represented by one byte. On the platforms
where type 'char' is signed, having the value with the upper bit set
(greater than 127) will result in a negative length when extracted.
That could lead to the 'scanRecordLength - nBytes' check provide
incorrect results. Also, the code that modifies the i variable could
behave wrong.

The similar problem exists for the advertising type byte. Types with
the upper bit set (e.g. manufacturer data) can be interpreted
incorrectly.

Fix it by explicitly converting to quint8. Conveniently, ARM platforms
(typical for Android) treat 'char' as unsigned, but there is a chance
that these issue could appear on Android x86.

Extend the tests with the case that will loop infinitely if the bug
is not fixed.

Task-number: QTBUG-145934
Pick-to: 6.11 6.8 6.5 5.15
Change-Id: I7f2e68c743cc6bfdca69a99bde8b46f4b4f9c2c6
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commit3128c8f906ee19635de658bf9f6c64b042df07a4
parentef08e378fc33e5cf2121cacb1c815fe9d370bc2e
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeWed, 29 Apr 2026 08:38:11 +0000