mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-16 05:34:32 -04:00
tests: Test that an overlong message is rejected
If one runs the test case without the fix for
d074d52902 ("connection: Dynamically resize connection buffers"), the
server spins and never processes the message. The test eventually times
out. With the fix, a protocol error is delivered to the client and the
test finishes immediately. The test covers both the default 4096-byte
buffer size and the case where the buffer size is large enough for the
message, but the message itself exceeds the 4096-byte limit. Both are
rejected.
The test relies on the definition of struct wl_proxy, so this definition
is moved to a client-specific private header. The definition itself is
not changed in any way.
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
This commit is contained in:
parent
cd0d1543c0
commit
3872a9362e
5 changed files with 195 additions and 57 deletions
|
|
@ -807,6 +807,51 @@ leak_after_error(void)
|
|||
free(c);
|
||||
}
|
||||
|
||||
static void
|
||||
too_long_message(void *arg)
|
||||
{
|
||||
#define TOO_LONG ((size_t)(4096 - 12 + 1))
|
||||
void *buf = malloc(TOO_LONG);
|
||||
assert(buf);
|
||||
memset(buf, 0, TOO_LONG);
|
||||
struct client *c = client_connect();
|
||||
struct wl_array arr = { TOO_LONG - 1, TOO_LONG, buf };
|
||||
set_buffer_size(c, *(uint32_t *)arg);
|
||||
long_request(c, &arr);
|
||||
wl_display_roundtrip(c->wl_display);
|
||||
assert(wl_display_get_error(c->wl_display) == 0);
|
||||
arr.size += 1;
|
||||
long_request(c, &arr);
|
||||
wl_display_dispatch(c->wl_display);
|
||||
assert(wl_display_get_error(c->wl_display) == EINVAL);
|
||||
wl_proxy_destroy((struct wl_proxy *) c->tc);
|
||||
wl_display_disconnect(c->wl_display);
|
||||
free(c);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
TEST(overlong_message_small_buffer)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
||||
uint32_t size = 4096;
|
||||
client_create(d, too_long_message, &size);
|
||||
display_run(d);
|
||||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
TEST(overlong_message_long_buffer)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
||||
uint32_t size = 8192;
|
||||
client_create(d, too_long_message, &size);
|
||||
display_run(d);
|
||||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
TEST(closure_leaks_after_error)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue