Reject messages not multiple of 4 bytes

At least libwayland and ocaml-wayland will never produce such messages,
and it is at best ambiguous whether they are allowed by the
specification.  There are also implementations of the Wayland protocol
that reject such messages, so using them has never been portable.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
This commit is contained in:
Demi Marie Obenour 2024-07-24 21:17:49 -04:00
parent 5b692b50b9
commit 87e2b7d6c2
3 changed files with 20 additions and 3 deletions

View file

@ -902,7 +902,14 @@ wl_connection_demarshal(struct wl_connection *connection,
/* Space for sender_id and opcode */
if (size < 2 * sizeof *p) {
wl_log("message too short, invalid header\n");
wl_log("message length %" PRIu32 " too short, invalid header\n", size);
wl_connection_consume(connection, size);
errno = EINVAL;
return NULL;
}
if (size % sizeof *p) {
wl_log("message length %" PRIu32 " invalid, not multiple of 4 bytes", size);
wl_connection_consume(connection, size);
errno = EINVAL;
return NULL;