summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2021-04-27 09:55:04 +0200
committerbakkeby <[email protected]>2021-04-27 09:55:04 +0200
commita7dfcc17d5903ef66555067f6cd226afa0b5310b (patch)
treea86e6763ae5897fe6fb86326949277ba4b226cd7 /patch
parent23c76d13b5376e78c268006da57d132883d5df9b (diff)
downloaddwm-flexipatch-a7dfcc17d5903ef66555067f6cd226afa0b5310b.tar.gz
dwm-flexipatch-a7dfcc17d5903ef66555067f6cd226afa0b5310b.zip
status2d: improving cut status line protection, dwm will still exit if an invalid color code comes through (there is an explicit die call in drw_clr_create)
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_status2d.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c
index e0d20a0..7784ac4 100644
--- a/patch/bar_status2d.c
+++ b/patch/bar_status2d.c
@@ -118,8 +118,9 @@ drawstatusbar(BarArg *a, char* stext)
while (text[++i] != '^') {
if (text[i] == 'c') {
char buf[8];
- if (i + 7 > len) {
+ if (i + 7 >= len) {
i += 7;
+ len = 0;
break;
}
memcpy(buf, (char*)text+i+1, 7);
@@ -134,8 +135,9 @@ drawstatusbar(BarArg *a, char* stext)
i += 7;
} else if (text[i] == 'b') {
char buf[8];
- if (i + 7 > len) {
+ if (i + 7 >= len) {
i += 7;
+ len = 0;
break;
}
memcpy(buf, (char*)text+i+1, 7);
@@ -204,11 +206,13 @@ drawstatusbar(BarArg *a, char* stext)
text = text + i + 1;
len -= i + 1;
- i=-1;
+ i = -1;
isCode = 0;
+ if (len <= 0)
+ break;
}
}
- if (!isCode) {
+ if (!isCode && len > 0) {
w = TEXTWM(text) - lrpad;
drw_text(drw, x, y, w, bh, 0, text, 0, True);
x += w;
@@ -216,7 +220,7 @@ drawstatusbar(BarArg *a, char* stext)
free(p);
drw_setscheme(drw, scheme[SchemeNorm]);
- return len - 1;
+ return 1;
}
int