From 281977c54200129a8701e8ab6bd60ffc3bb51448 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 30 Oct 2024 21:05:00 +0100 Subject: [PATCH] Avoid unsigned integer underflow in drw_text() ref. https://git.suckless.org/dwm/commit/cfb8627a80a334f200f68c2c8f3e384313ebbaf5.html --- README.md | 2 +- drw.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e684c12..5afb94d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This dwm 6.5 (fcb2476, 2024-10-27) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). +This dwm 6.5 (cfb8627, 2024-10-28) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. Due to the complexity of some of the patches dwm-flexipatch has diverged from mainstream dwm by making some core patches non-optional for maintenance reasons. For the classic dwm-flexipatch build refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0). For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h): ```c diff --git a/drw.c b/drw.c index 37da31b..8a479fb 100644 --- a/drw.c +++ b/drw.c @@ -436,6 +436,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + if (w < lpad) + return x + w; #if BAR_ALPHA_PATCH d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); #else @@ -510,6 +512,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + if (w < lpad) + return x + w; #if BAR_ALPHA_PATCH d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); #else