1829 Commits

Author SHA1 Message Date
Aryadev Chavali
c35f717e61 update dwm.1 2026-03-08 02:07:24 +00:00
Aryadev Chavali
682ddf79d6 Update to 6.8 2026-03-08 02:07:13 +00:00
NRK
c3dd6a829b more overflow fix in getatomprop()
commit 244fa852 (and a9aa0d8) tried to fix overflow by checking
the number of items returned. however this is not sufficient
since the format may be lower than 32 bits.

to reproduce the crash, i used the reproducer given in commit
244fa85 but changed the XChangeProperty line to the following to
set the property to a 1 element 16 bit item:

	short si = 1;
	XChangeProperty(d, w, net_wm_state, XA_ATOM, 16,
		PropModeReplace, (unsigned char *)&si, 1);

this client reliably crashes dwm under ASAN since dwm is trying
to read a 32 bit value from a 16 bit one. fix it by checking for
format == 32 as well.

also change the access type from Atom to long, on my machine
Atom is typedef-ed to long already but that may not be true
everywere. the XGetWindowProperty manpage says format == 32 is
returned as `long` so use `long` directly.

(N.B: it also might be worth checking if the returned type is
 XA_ATOM as well, but i wasn't able to cause any crashes by
 setting different types so i'm leaving it out for now.)
2026-02-20 15:31:29 +01:00
NRK
5c9f30300b getstate: fix access type and remove redundant cast
WM_STATE is defined to be format == 32 which xlib returns as
`long` and so accessing it as `unsigned char` is incorrect.

and also &p is already an `unsigned char **` and so the cast was
completely redundant.

given the redundant cast, i assume `p` was `long *` at some time
but was changed to `unsigned char *` later, but the pointer
access (and the cast) wasn't updated.

also add a `format == 32` check as safety measure before
accessing, just in case.
2026-02-20 15:31:28 +01:00
NRK
397d618f1c fix not updating _NET_ACTIVE_WINDOW
currently clients that set the input field of WM_HINTS to true
(c->neverfocus) will never be updated as _NET_ACTIVE_WINDOW even
when they are focused. according to the ICCCM [0] the input
field of WM_HINTS tells the WM to either use or not use
XSetInputFocus(), it shouldn't have any relation to
_NET_ACTIVE_WINDOW. EWMH spec [1] also does not mention any
relationship between the two.

this issue was noticed when launching games via steam/proton and
noticing that _NET_ACTIVE_WINDOW was always wrong/stale (i.e not
updated to the game window).

for reference I've looked at bspwm [2] and it also seems to set
_NET_ACTIVE_WINDOW regardless of whether the client has WM_HINTS
input true or not.

[0]: https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#input_focus
[1]: https://specifications.freedesktop.org/wm/1.5/ar01s03.html#id-1.4.10
[2]: c5cf7d3943/src/tree.c (L659-L662)
2026-02-13 10:16:08 +01:00
Hiltjo Posthuma
f63cde9354 bump version to 6.8 2026-01-30 11:18:38 +01:00
Chris Down
a9aa0d8ffb dwm: Fix getatomprop regression from heap overflow fix
Commit 244fa852fe ("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.
2026-01-16 14:13:51 +01:00
Hiltjo Posthuma
85fe518c1a bump version to 6.7
Put the maintainer at the top and bump years (time flies).
2026-01-10 11:31:44 +01:00
Chris Down
244fa852fe dwm: Fix heap buffer overflow in getatomprop
When getatomprop() is called, it invokes XGetWindowProperty() to
retrieve an Atom. If the property exists but has zero elements (length
0), Xlib returns Success and sets p to a valid, non-NULL memory address
containing a single null byte.

However, dl (that is, the number of items) is 0. dwm blindly casts p to
Atom* and dereferences it. While Xlib guarantees that p is safe to read
as a string (that is, it is null-terminated), it does _not_ guarantee it
is safe to read as an Atom (an unsigned long).

The Atom type is a typedef for unsigned long. Reading an Atom (which
thus will either likely be 4 or 8 bytes) from a 1-byte allocated buffer
results in a heap buffer overflow. Since property content is user
controlled, this allows any client to trigger an out of bounds read
simply by setting a property with format 32 and length 0.

An example client which reliably crashes dwm under ASAN:

    #include <X11/Xlib.h>
    #include <X11/Xatom.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>

    int main(void) {
        Display *d;
        Window root, w;
        Atom net_wm_state;

        d = XOpenDisplay(NULL);
        if (!d) return 1;

        root = DefaultRootWindow(d);
        w = XCreateSimpleWindow(d, root, 10, 10, 200, 200, 1, 0, 0);
        net_wm_state = XInternAtom(d, "_NET_WM_STATE", False);
        if (net_wm_state == None) return 1;

        XChangeProperty(d, w, net_wm_state, XA_ATOM, 32,
                        PropModeReplace, NULL, 0);
        XMapWindow(d, w);
        XSync(d, False);
        sleep(1);

        XCloseDisplay(d);
        return 0;
    }

In order to avoid this, check that the number of items returned is
greater than zero before dereferencing the pointer.
2026-01-10 11:27:23 +01:00
Aryadev Chavali
6b73119c22 Add some more cflags to config.mk 2025-11-26 03:55:13 +00:00
Aryadev Chavali
c3eb171738 Made patch for dwm-scratchpad-ensure-tag 2025-11-26 03:55:09 +00:00
Aryadev Chavali
6426d580be scratchpad: Ensure new clients spawned by scratchpad go to underlying tag
Came from following: https://prithu.dev/posts/debugging-dwm/.  An
issue I thought I had to live with is actually trivial to fix!  Full
credit to them.
2025-11-26 03:55:09 +00:00
Aryadev Chavali
43c355c489 Revert fibonacci, gaplessgrid, centered{master,floatingmaster} patches 2025-11-26 03:55:09 +00:00
Aryadev Chavali
6eb2ae7c8b Delete old layouts from explanation in dwm.1 2025-11-26 03:27:22 +00:00
Aryadev Chavali
f26327a181 Make selected client have a white border 2025-11-26 03:25:18 +00:00
Aryadev Chavali
879e7d351d Add focusonactive patch to DWM
When an application tags itself as "active" i.e. has something to do,
this patch will ensure that we're focused on it.  Works on multiple
monitors!
2025-11-26 03:23:30 +00:00
Aryadev Chavali
acd431e3ef Add a border, change up some colours 2025-11-16 22:32:34 +00:00
Aryadev Chavali
7d4682c5ed Make monocle the default layout and set a better geometry for the scratchpad 2025-10-23 00:30:52 +01:00
Aryadev Chavali
46678629bd set pertag->gaps_previous to defualt_gaps 2025-10-15 23:20:19 +01:00
Hiltjo Posthuma
7c3abae4e6 drw.c: drw_scm_free: call free inside
Because drw_scm_create() allocates it.
2025-09-29 18:48:27 +02:00
Hiltjo Posthuma
93f26863d1 cleanup schemes and colors 2025-09-27 12:10:17 +02:00
Aryadev Chavali
71dc068273 Disable some layouts and clean up window rules 2025-08-20 21:17:21 +01:00
Hiltjo Posthuma
74edc27caa config: make refreshrate for mouse move/resize a config option
Bump the default from 60 to 120.
2025-08-12 19:17:20 +02:00
Hiltjo Posthuma
693d94d350 bump version to 6.6 2025-08-09 14:34:03 +02:00
Aryadev Chavali
fd3f2a2b6d Add a watch script
For you kiddies who need "hot reloading" on configuration change.
2025-05-28 23:25:09 +01:00
Aryadev Chavali
893e065272 Adjust README 2025-05-28 23:25:05 +01:00
Aryadev Chavali
ae3a76f7c5 adjust config 2025-05-28 23:24:37 +01:00
Aryadev Chavali
dd3eddb961 Add dwm.org for tasks 2025-05-28 23:24:19 +01:00
Aryadev Chavali
75d61fe3c4 Fix README 2024-12-04 02:17:50 +00:00
Aryadev Chavali
438dec38a3 Remove spawning shell command 2024-12-03 04:33:12 +00:00
Aryadev Chavali
401cc64cef Edit README for some extra tips. 2024-11-01 06:31:52 +00:00
Aryadev Chavali
21d9094b45 Remove old entries from rules array. 2024-11-01 06:30:01 +00:00
Aryadev Chavali
0837a17cc2 Current gaps are set to default_gaps at init 2024-11-01 06:12:33 +00:00
Aryadev Chavali
e8462f62cf movekeyboard now does 32 instead of 20 pixel movements. 2024-11-01 06:11:14 +00:00
Aryadev Chavali
eecb990e1d Align variables, snap_pixel 32 -> 16, default_gaps 40 -> 50 2024-11-01 06:10:20 +00:00
Raymond Cole
cfb8627a80 Avoid unsigned integer underflow in drw_text() 2024-10-30 13:02:17 +01:00
Hiltjo Posthuma
fcb2476b69 util.c: output function might override errno and thus affect perror()
Original patch by Raymond Cole with some modifications, thanks!
2024-10-27 20:10:07 +01:00
Aryadev Chavali
71bc6de8b4 Make keys easier to write and look at 2024-10-20 16:52:17 +01:00
Aryadev Chavali
3577236175 Change scratchpad from Emacs back to st 2024-10-20 16:37:10 +01:00
Aryadev Chavali
17f5dfa814 Added patch to move floating windows via the keyboard 2024-10-20 16:36:58 +01:00
Aryadev Chavali
84d550ca9b Switch scratchpad to Emacs, make col_black proper black 2024-10-05 15:40:50 +01:00
Hiltjo Posthuma
8933ebcf50 sync drw.{c,h} from dmenu
- drw: minor improvement to the nomatches cache
- overhaul utf8decoding and render invalid utf8 sequences as U+FFFD.

Thanks NRK for these improvements!
2024-10-05 13:06:08 +02:00
Aryadev Chavali
8ae7be5d52 Modified README, adding optional libxinerma requirement 2024-08-07 21:31:31 +01:00
Aryadev Chavali
d410194f20 Modified README to look nicer 2024-08-07 21:28:13 +01:00
Aryadev Chavali
ec3c800ee5 Update README 2024-08-07 21:20:49 +01:00
Aryadev Chavali
e544c9c024 Change rule for mpv and remove rule for media-term (obsolete) 2024-08-07 21:17:11 +01:00
Aryadev Chavali
67df7a09ed Two arrays of gaps are stored in pertag, switchable by toggle_gaps
With this commit, each tag has two gap values (indexes at
`gaps_previous`, `gaps_current`) that can be interchanged via
`toggle_gaps`.  At initialisation, `gaps_previous` is set to
`default_gaps` and `gaps_current` is set to all 0.
2024-07-25 23:41:08 +01:00
Aryadev Chavali
5f9fcc88d1 Add patch for deferring focus 2024-07-24 16:22:21 +01:00
Aryadev Chavali
7c67af1e81 Defer focusing on sticky windows on switching tags
focus(NULL) is called when switching to a new tag or monitor.  I don't
want sticky windows to get first focus in this situation, hence this
code.  Shamelessly stolen from
https://github.com/LukeSmithxyz/dwm/issues/152.
2024-07-24 16:21:12 +01:00
Aryadev Chavali
a5ef1a0a85 Added dwm-sticky patch
Make sticky windows, which are kinda like Mod-Shift-0 tagged windows
but easier to manage.
2024-07-24 16:19:34 +01:00