Compare commits

..

9 Commits
6.7 ... master

Author SHA1 Message Date
1bae806fe5 fix: comment out main, so there is only one main signature.
dwm.c also has a main function defined.
2026-01-25 12:46:27 +01:00
2f76a5cc49 fix: forgot to include half of the libraries. 2026-01-25 12:46:04 +01:00
ab2253a0ee Ignore compile_commands.json 2026-01-25 12:39:49 +01:00
c23f9dfe2e Move config.mk into Makefile, and delete config.mk.
config.mk shall now contain user-specific configurations, and thus is
now ignored.
2026-01-25 12:39:49 +01:00
eda3495acf fix: change = to := 2026-01-25 12:37:29 +01:00
1448916be3 Rework makefile and worktree.
Moved most source files to /src/
Renamed `LICENSE` to `COPYING` to reduce (my personal) misspellings.
Rewrote Makefile to be more Quinn-friendly, and removed some components
not necessary for me, since this is a personal project.
2026-01-25 12:20:47 +01:00
f12825443e Specify /bin specifically, as opposed to any directory called bin/ 2026-01-25 09:23:53 +01:00
c750f87edd Add .gitignore 2026-01-19 19:12:47 +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
12 changed files with 102 additions and 72 deletions

20
.gitignore vendored Normal file
View File

@@ -0,0 +1,20 @@
# Ignore dotfiles by default
.*
# Ignore common (generated) file types
*.a
*.o
*.d
*.so
*.out
*.hex
*.gz
# Ignore specific project files
compile_commands.json
/bin/
/config.mk
# Unignore specific files.
!.gitignore
!.clang-format

View File

107
Makefile
View File

@@ -1,45 +1,92 @@
# dwm - dynamic window manager # dwm - dynamic window manager
# See LICENSE file for copyright and license details. # See LICENSE file for copyright and license details.
include config.mk -include config.mk
SRC = drw.c dwm.c util.c VERSION = 6.7
OBJ = ${SRC:.c=.o}
all: dwm INSTALL ?= install
GZIP ?= gzip
TAR ?= tar
.c.o: CFLAGS := -Os $(CFLAGS) -g -std=gnu99\
${CC} -c ${CFLAGS} $< -Wall -Wextra -Wpedantic -Wno-pointer-arith
CPPFLAGS := -DNDEBUG $(CPPFLAGS)\
-DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700L -DXINERAMA
LDFLAGS := -flto $(LDFLAGS)
LDLIBS := $(LDLIBS) -lm
${OBJ}: config.h config.mk # Use pkg-config to locate dependencies, and set the correct flags.
ifeq (,$(shell command -v pkg-config))
$(error Failed to locate pkg-config, please make sure it is installed or acessible through PATH.)
else
CPPFLAGS += $(shell pkg-config --cflags-only-I fontconfig freetype2 x11 xft xinerama)
LDFLAGS += $(shell pkg-config --libs-only-L fontconfig freetype2 x11 xft xinerama)
LDLIBS += $(shell pkg-config --libs-only-l fontconfig freetype2 x11 xft xinerama)
endif
config.h: SRC := $(wildcard src/*.c)
cp config.def.h $@ OBJ := $(addsuffix .o,$(SRC))
DEP := $(addsuffix .d,$(SRC))
dwm: ${OBJ} # Set Q to @ to silence commands being printed, unless --no-silent has been set
${CC} -o $@ ${OBJ} ${LDFLAGS} ifeq (0, $(words $(findstring --no-silent,$(MAKEFLAGS))))
Q=@
endif
clean: msg = @printf '%-8s %s\n' "$(1)" "$(2)"
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
dist: clean .PHONY:
mkdir -p dwm-${VERSION} all: bin/dwm
cp -R LICENSE Makefile README config.def.h config.mk\
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
gzip dwm-${VERSION}.tar
rm -rf dwm-${VERSION}
install: all .PHONY:
mkdir -p ${DESTDIR}${PREFIX}/bin install: $(DESTDIR)/bin/dwm $(DESTDIR)/share/man/man1/dwm.1.gz
cp -f dwm ${DESTDIR}${PREFIX}/bin $(DESTDIR)/bin/%: bin/%
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm $(call msg,INSTALL,$@)
mkdir -p ${DESTDIR}${MANPREFIX}/man1 $(Q)$(INSTALL) -D -m0755 $< $@
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
$(DESTDIR)/share/man/%: man/%
$(call msg,INSTALL,$@)
$(Q)$(INSTALL) -D -m0644 $< $@
.PHONY:
uninstall: uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\ $(Q)$(RM) $(DESTDIR)/bin/dwm\
${DESTDIR}${MANPREFIX}/man1/dwm.1 $(DESTDIR)/share/man/man1/dwm.1.gz
.PHONY: all clean dist install uninstall .PHONY:
clean:
$(call msg,CLEAN,src/)
$(Q)$(RM) $(OBJ)
$(call msg,CLEAN,man/)
$(Q)$(RM) $(MAN)
$(call msg,CLEAN,bin/)
$(Q)$(RM) -r bin/
# Links together the object files into the final binary.
bin/dwm: $(OBJ) | bin/
$(call msg,LD,$@)
$(Q)$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
# Compiles C sources into Object files
%.c.o: %.c
$(call msg,CC,$@)
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
# Compress files requested for compression using GZIP
%.gz: %
$(call msg,GZIP,$@)
$(Q)$(GZIP) -k $<
# Create directories
%/:
$(call msg-mkdir,$@)
$(Q)mkdir $@
# Generate and include dependencies,
# ignoring any errors that may occur when doing so.
%.c.d: %.c
$(Q)$(CC) -MM $(CPPFLAGS) -MF $@ $<
ifeq (0, $(words $(findstring $(MAKECMDGOALS), clean)))
-include $(DEP)
endif

View File

@@ -1,39 +0,0 @@
# dwm version
VERSION = 6.7
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
# freetype
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
#MANPREFIX = ${PREFIX}/man
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
LDFLAGS = ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
# compiler and linker
CC = cc

View File

View File

View File

@@ -864,13 +864,13 @@ Atom
getatomprop(Client *c, Atom prop) getatomprop(Client *c, Atom prop)
{ {
int di; int di;
unsigned long dl; unsigned long nitems, dl;
unsigned char *p = NULL; unsigned char *p = NULL;
Atom da, atom = None; Atom da, atom = None;
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
&da, &di, &dl, &dl, &p) == Success && p) { &da, &di, &nitems, &dl, &p) == Success && p) {
if (dl > 0) if (nitems > 0)
atom = *(Atom *)p; atom = *(Atom *)p;
XFree(p); XFree(p);
} }

View File

@@ -5,6 +5,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
/*
int main(void) { int main(void) {
Display *d; Display *d;
Window r, f, t = None; Window r, f, t = None;
@@ -40,3 +41,4 @@ int main(void) {
XCloseDisplay(d); XCloseDisplay(d);
exit(0); exit(0);
} }
*/

View File

View File