summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2026-01-14 14:58:05 +0800
committerHiltjo Posthuma <hiltjo@codemadness.org>2026-01-16 14:13:51 +0100
commita9aa0d8ffbb548b0b1f9f755557aef2482c0f820 (patch)
tree1b104e0725530dfb437f732a53a49e01a2c0a913 /dwm.c
parentbump version to 6.7 (diff)
downloaddwm-a9aa0d8ffbb548b0b1f9f755557aef2482c0f820.tar.gz
dwm-a9aa0d8ffbb548b0b1f9f755557aef2482c0f820.zip
dwm: Fix getatomprop regression from heap overflow fix
Commit 244fa852fe27 ("dwm: Fix heap buffer overflow in getatomprop") introduced a check for dl > 0 before dereferencing the property pointer. However, I missed that the variable dl is passed to XGetWindowProperty for both nitems_return and bytes_after_return parameters: XGetWindowProperty(..., &dl, &dl, &p) The final value in dl is bytes_after_return, not nitems_return. For a successfully read property, bytes_after is typically 0 (indicating all data was retrieved), so the check `dl > 0` is always false and dwm never reads any atom properties. So this is safe, but not very helpful :-) dl is probably just a dummy variable anyway, so fix by using a separate variable for nitems, and check nitems > 0 as originally intended.
Diffstat (limited to '')
-rw-r--r--dwm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index 8f4fa75..53b393e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -864,13 +864,13 @@ Atom
864getatomprop(Client *c, Atom prop) 864getatomprop(Client *c, Atom prop)
865{ 865{
866 int di; 866 int di;
867 unsigned long dl; 867 unsigned long nitems, dl;
868 unsigned char *p = NULL; 868 unsigned char *p = NULL;
869 Atom da, atom = None; 869 Atom da, atom = None;
870 870
871 if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, 871 if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
872 &da, &di, &dl, &dl, &p) == Success && p) { 872 &da, &di, &nitems, &dl, &p) == Success && p) {
873 if (dl > 0) 873 if (nitems > 0)
874 atom = *(Atom *)p; 874 atom = *(Atom *)p;
875 XFree(p); 875 XFree(p);
876 } 876 }