From 13f35139d39f3ec40f1f7a20ae15161ef04f03bd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 21 Jul 2020 13:15:00 +0200 Subject: [PATCH] xwayland/xwm: add prop count assert in xsurface_set_net_wm_state This helps mitigate buffer overflows. --- xwayland/xwm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 50a85985..a34d56a2 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -294,10 +294,9 @@ static void xwm_surface_activate(struct wlr_xwm *xwm, static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) { struct wlr_xwm *xwm = xsurface->xwm; - uint32_t property[5]; - int i; - i = 0; + uint32_t property[5]; + size_t i = 0; if (xsurface->modal) { property[i++] = xwm->atoms[NET_WM_STATE_MODAL]; } @@ -313,6 +312,7 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) { if (xsurface->minimized) { property[i++] = xwm->atoms[NET_WM_STATE_HIDDEN]; } + assert(i <= sizeof(property) / sizeof(property[0])); xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE,