sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 66ce520d4a5ac684fda9b3e40dd8236d54e804db
parent 614f47272b4759fd722fc1f7095ebbc9061190c4
Author: AdamYuan <y13916619121@126.com>
Date:   Fri, 23 Jul 2021 13:42:32 +0800

[dwm][patch][winicon] Prevent potential pointer overflow

Diffstat:
Mdwm.suckless.org/patches/winicon/dwm-winicon-6.2-v1.3.diff | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/dwm.suckless.org/patches/winicon/dwm-winicon-6.2-v1.3.diff b/dwm.suckless.org/patches/winicon/dwm-winicon-6.2-v1.3.diff @@ -81,7 +81,7 @@ index 4bcd5ad..07b6433 100644 /* Map functions */ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/dwm.c b/dwm.c -index 4465af1..850dbbf 100644 +index 4465af1..b02a80c 100644 --- a/dwm.c +++ b/dwm.c @@ -28,6 +28,8 @@ @@ -183,16 +183,16 @@ index 4465af1..850dbbf 100644 + const unsigned long *end = p + n; + unsigned long *i; + uint32_t bstd = UINT32_MAX, d, m; -+ for (i = p; i + 1 < end; ) { ++ for (i = p; i < end - 1; i += sz) { + if ((w = *i++) > UINT16_MAX || (h = *i++) > UINT16_MAX) { XFree(p); return NULL; } -+ m = w > h ? w : h; sz = w * h; -+ if ((i += sz) <= end && m >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i - sz; } ++ if ((sz = w * h) > end - i) break; ++ if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; } + } + if (!bstp) { -+ for (i = p; i + 1 < end; ) { ++ for (i = p; i < end - 1; i += sz) { + if ((w = *i++) > UINT16_MAX || (h = *i++) > UINT16_MAX) { XFree(p); return NULL; } -+ m = w > h ? w : h; sz = w * h; -+ if ((i += sz) <= end && (d = ICONSIZE - m) < bstd) { bstd = d; bstp = i - sz; } ++ if ((sz = w * h) > end - i) break; ++ if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; } + } + } + if (!bstp) { XFree(p); return NULL; }