BlueZ: check packet size before casting to MgmtEventDeviceFound


The code that is parsing the Bluetooth Management commands was checking
the size of the MgmtHdr before extracting it, but was never checking
that the MgmtHdr::length parameter actually a value that is enough to
fit the MgmtEventDeviceFound struct.

If the actual length of the data was less than the size of the
MgmtEventDeviceFound struct, we were reading the data past the end of
the buffer.

Note that this was very unlikely to happen in practice, because the
incorrect data has to be sent from the Linux kernel or from a malicious
privileged process.

Task-number: QTBUG-145934
Pick-to: 6.11 6.8
Change-Id: I4be6a6d42c97490054f10d34dd86c0a70875157b
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commit546dcdd6c3402b5e5b2daf95584f2f364dbad3d5
parent3b8158b23c7db594bcded837c782053843a3d15a
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeThu, 23 Apr 2026 15:24:24 +0000