diff options
author | Simon Ser <contact@emersion.fr> | 2023-01-24 23:51:57 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-01-25 11:12:59 +0100 |
commit | be31c5a8c852a57007f9a4115bd3e082c089acf1 (patch) | |
tree | b4199f79e95d8793f27e4eb964abff834f4d93c6 | |
parent | 9700155edaae37bf91b55b58c1c2adf2ed142282 (diff) | |
download | wayland-be31c5a8c852a57007f9a4115bd3e082c089acf1.tar.gz |
server: fail on global name overflow
display->id is initialized to 1, making 0 a convenient value to
indicate an invalid global name. Make sure to not return a zero
global name on overflow. Moreover, if we wrap around, we might
cycle back to a global name which is already in-use.
Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r-- | src/wayland-server.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index ee53f76..f7e0e6b 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1285,6 +1285,11 @@ wl_global_create(struct wl_display *display, return NULL; } + if (display->id >= UINT32_MAX) { + wl_log("wl_global_create: ran out of global names\n"); + return NULL; + } + global = zalloc(sizeof *global); if (global == NULL) return NULL; |