summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2026-10-13 14:30:47 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2026-10-16 13:25:55 +0200
commit3fdf0241fcd1b7677a034c0c8f213587e5e706e7 (patch)
tree611806cd8e921c2b5c3248b4f23f5181526e5cd9
parentcheck and restrict size hint values (diff)
downloaddwm-3fdf0241fcd1b7677a034c0c8f213587e5e706e7.tar.gz
dwm-3fdf0241fcd1b7677a034c0c8f213587e5e706e7.zip
ignore malformed ConfigureNotify with width or height <= 0
This could crash dwm. cc repro.c -o repro -lX11; ./repro int main(void) { Display *d; int screen; Window root; d = XOpenDisplay(NULL); if (!d) { fprintf(stderr, "XOpenDisplay failed\n"); return 1; } screen = DefaultScreen(d); root = RootWindow(d, screen); XConfigureEvent ce = {0}; ce.type = ConfigureNotify; ce.display = d; ce.event = root; ce.window = root; ce.width = 0; ce.height = 0; XSendEvent(d, root, False, StructureNotifyMask, (XEvent *)&ce); XFlush(d); XCloseDisplay(d); return 0; }
-rw-r--r--dwm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 5ff6fd4..1249997 100644
--- a/dwm.c
+++ b/dwm.c
@@ -559,6 +559,9 @@ configurenotify(XEvent *e)
559 559
560 /* TODO: updategeom handling sucks, needs to be simplified */ 560 /* TODO: updategeom handling sucks, needs to be simplified */
561 if (ev->window == root) { 561 if (ev->window == root) {
562 if (ev->width <= 0 || ev->height <= 0)
563 return;
564
562 dirty = (sw != ev->width || sh != ev->height); 565 dirty = (sw != ev->width || sh != ev->height);
563 sw = ev->width; 566 sw = ev->width;
564 sh = ev->height; 567 sh = ev->height;