dmenu

dynamic menu
git clone git://git.suckless.org/dmenu
Log | Files | Refs | README | LICENSE

commit 0785a28f1d6e27e18ab998d20b0390e2c3ec226c
parent 5453bb65d98b466ea38494a867358fc9eed2250f
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 13 Sep 2026 20:39:14 +0200

fix out-of-bounds read of the Xinerama screen array with no screens

This can happen if dmenu is run with Xinerama enabled and no screens are
detected.

Also fallback to the first screen if there is no intersection of the root
pointer to the screens found.

Reported by: jb19357 <jb19357@protonmail.com>
Who used Claude to write a report.

I cannot reproduce this issue, but it seems logical.

Diffstat:
Mdmenu.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/dmenu.c b/dmenu.c @@ -639,6 +639,8 @@ setup(void) #ifdef XINERAMA i = 0; if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { + if (n < 1) + die("Xinerama reported no screens"); XGetInputFocus(dpy, &w, &di); if (mon >= 0 && mon < n) i = mon; @@ -661,6 +663,9 @@ setup(void) for (i = 0; i < n; i++) if (INTERSECT(x, y, 1, 1, info[i]) != 0) break; + /* fallback to the first screen if there is no intersection */ + if (i >= n) + i = 0; x = info[i].x_org; y = info[i].y_org + (topbar ? 0 : info[i].height - mh);