Handle invalid format for a Registry packet
The name "Registry" is reserved by Qt Remote Objects for a special
Registry source. The protocol therefore expects a specific format of
a packet when a new client connects to the registry - the packet must
have one argument of the type QRemoteObjectSourceLocation.
However, nothing prevents the users from registering a custom object
under the name "Registry". An attempt to call a slot with no arguments
for such an object triggers a crash when trying to access the first
argument.
An alternative way to trigger the crash is to send a raw InvokePacket
command.
This patch fixes it by explicitly verifying the number of arguments
and checking that the first argument can be converted to the proper
type. The new unit-test was crashing without the fix.
Ideally it should be prohibited to register custom objects under the
name "Registry", but I cannot immediately tell if it can break any
valid usecase or not, so it is left for a follow-up patch.
Task-number: QTBUG-150775
Pick-to: 6.12 6.8 6.5 5.15
Change-Id: I5c54d4b19b57560f87dec6beb7deeabecbbe8c93
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>