aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2021-05-19 20:48:18 -0400
committerSimon Ser <contact@emersion.fr>2021-05-31 10:41:29 +0200
commit6605d7c390279faa77f959bc3ad83148226daea8 (patch)
tree9bebc43df474b4c4435f41a7653ae097eeb9805d
parentae2f3ecb6824e168083580a601af53d6c9544b5d (diff)
xwm: prevent X11 clients from blowing our stack by opening too many windows
Allocate window arrays for list property updates on the heap instead.
-rw-r--r--xwayland/xwm.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 845b98cc..2be41168 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -237,7 +237,11 @@ static void xwm_set_net_client_list(struct wlr_xwm *xwm) {
}
}
- xcb_window_t windows[mapped_surfaces + 1];
+ xcb_window_t *windows = malloc(sizeof(xcb_window_t) * mapped_surfaces);
+ if (!windows) {
+ return;
+ }
+
size_t index = 0;
wl_list_for_each(surface, &xwm->surfaces, link) {
if (surface->mapped) {
@@ -248,11 +252,15 @@ static void xwm_set_net_client_list(struct wlr_xwm *xwm) {
xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE,
xwm->screen->root, xwm->atoms[NET_CLIENT_LIST],
XCB_ATOM_WINDOW, 32, mapped_surfaces, windows);
+ free(windows);
}
static void xwm_set_net_client_list_stacking(struct wlr_xwm *xwm) {
size_t num_surfaces = wl_list_length(&xwm->surfaces_in_stack_order);
- xcb_window_t windows[num_surfaces + 1];
+ xcb_window_t *windows = malloc(sizeof(xcb_window_t) * num_surfaces);
+ if (!windows) {
+ return;
+ }
// We store surfaces in top-to-bottom order because this is easier to reason
// about, but _NET_CLIENT_LIST_STACKING is supposed to be in bottom-to-top
@@ -266,6 +274,7 @@ static void xwm_set_net_client_list_stacking(struct wlr_xwm *xwm) {
xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE, xwm->screen->root,
xwm->atoms[NET_CLIENT_LIST_STACKING], XCB_ATOM_WINDOW, 32, num_surfaces,
windows);
+ free(windows);
}
static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface);