URI:
       dwm: Fix getatomprop regression from heap overflow fix - dwm - my customized version of dwm (hiltjo branch)
  HTML git clone git://git.codemadness.org/dwm
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit a9aa0d8ffbb548b0b1f9f755557aef2482c0f820
   DIR parent 85fe518c1af5eb43f222f4d8579e4814ed769f3b
  HTML Author: Chris Down <chris@chrisdown.name>
       Date:   Wed, 14 Jan 2026 14:58:05 +0800
       
       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:
         M dwm.c                               |       6 +++---
       
       1 file changed, 3 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/dwm.c b/dwm.c
       @@ -864,13 +864,13 @@ Atom
        getatomprop(Client *c, Atom prop)
        {
                int di;
       -        unsigned long dl;
       +        unsigned long nitems, dl;
                unsigned char *p = NULL;
                Atom da, atom = None;
        
                if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
       -                &da, &di, &dl, &dl, &p) == Success && p) {
       -                if (dl > 0)
       +                &da, &di, &nitems, &dl, &p) == Success && p) {
       +                if (nitems > 0)
                                atom = *(Atom *)p;
                        XFree(p);
                }