mirror of
git://git.suckless.org/dmenu
synced 2026-09-23 00:16:30 +01:00
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.
This commit is contained in:
parent
5453bb65d9
commit
0785a28f1d
5
dmenu.c
5
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user