From be31c5a8c852a57007f9a4115bd3e082c089acf1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 24 Jan 2023 23:51:57 +0100 Subject: [PATCH] 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 --- src/wayland-server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wayland-server.c b/src/wayland-server.c index ee53f764..f7e0e6b2 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;