connection: fix demarshal of invalid header
The size argument to wl_connection_demarshal() is taken from the message by the
caller wl_client_connection_data(), therefore 'size' is untrusted data
controllable by a Wayland client. The size should always be at least the header
size, otherwise the header is invalid.
If the size is smaller than header size, it leads to reading past the end of
allocated memory. Furthermore if size is zero, wl_closure_init() changes
behaviour and leaves num_arrays uninitialized, leading to access of arbitrary
Check that 'size' fits at least the header. The space for arguments is already
This makes the request_bogus_size test free of errors under Valgrind.
Signed-off-by: Pekka Paalanen <email@example.com>
Reviewed-by: Simon Ser <firstname.lastname@example.org>
2 files changed