Merge branch 'strict-message-size' into 'main'

Require messages to use as few bytes as possible

See merge request wayland/wayland!416
This commit is contained in:
Demi Marie Obenour 2026-01-25 06:50:47 -05:00
commit 6ba271fd4a
3 changed files with 28 additions and 3 deletions

View file

@ -904,7 +904,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;
@ -1072,6 +1079,12 @@ wl_connection_demarshal(struct wl_connection *connection,
}
}
if (p != end) {
wl_log("trailing junk\n");
errno = EINVAL;
goto err;
}
wl_connection_consume(connection, size);
return closure;