Wireshark-dev: [Wireshark-dev] Calling a dissector: Type for data parameter

From: Uli Heilmeier <zeugs@xxxxxxxxxxxx>
Date: Sat, 29 May 2021 09:06:54 +0200
With MR 2706 [1] the MQTT dissector calls now subdissectors with call_dissector_with_data() [2]. Previously this was call_dissector().

With this change the JSON dissector crashes WS with a memory access segfault (while using MQTT decode topic as option).
This is because for JSON we expect http_message_info_t for data pointer [3]. MQTT hands over a pointer to a char array (topic_str) for data.

How do we handle data type for the data parameter pointer? Would it make sense to compare at least the size of data with the size of http_message_info_t?

I don’t know any way to check the data type of a pointer address location.

Cheers
Uli

[1]: https://gitlab.com/wireshark/wireshark/-/merge_requests/2706/
[2]: https://gitlab.com/wireshark/wireshark/-/merge_requests/2706//diffs#07171e000b3caaabee32ab5dc04a5d28efbaaae3_755_755
[3]: https://gitlab.com/wireshark/wireshark/-/blob/master/epan/dissectors/packet-json.c#L221