Handle property count mismatch when acquiring replicas
The replica initialization always assumed that the incoming
InitPacket has the same number of properties as the replica
expects.
If more properties are sent, then
QConnectedReplicaImplementation::initialize() method reads and
writes past the end of m_propertyStorage.
If less properties are sent, it is only an issue when the
replica has child replicas (QObject-based properties). In such
case handlePointerToQObjectProperties() helper method may read
past the end of the input, if the nested replica index is larger
than the actual number of sent properties.
Fix both by verifying that the sent and the expected number of
properties matches.
Since we're in the initialization step, if they mismatch, we can
simply move the replica into SignatureMismatch state and
disconnect it from the source.
Do this for both static and dynamic replicas. In case of the
dynamic replica, the source sends both metaobject definition and
the initial property values. But nothing verified that they match
each other.
The last issue addressed in this patch is the nested replicas.
They can have property count mismatch on their own. So, add
similar property count checks in handlePointerToQObjectProperty().
Add two new unit-tests that handle property count mismatch in a
top-level replica and in a child replica.
Fixes: QTBUG-150780
Pick-to: 6.12 6.8 6.5 5.15
Change-Id: Id53c167851a730f25bb75234a8e9ba21373c50ff
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>