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;
}
This commit is contained in:
Hiltjo Posthuma committed 2026-10-16 13:25:55 +02:00
1 parent 7283c8c0ac
commit 3fdf0241fc
1 file changed
+3
+3
View File
@@ -559,6 +559,9 @@ configurenotify(XEvent *e)
/* TODO: updategeom handling sucks, needs to be simplified */ /* TODO: updategeom handling sucks, needs to be simplified */
if (ev->window == root) { if (ev->window == root) {
if (ev->width <= 0 || ev->height <= 0)
return;
dirty = (sw != ev->width || sh != ev->height); dirty = (sw != ev->width || sh != ev->height);
sw = ev->width; sw = ev->width;
sh = ev->height; sh = ev->height;