[hackers] [dwm][PATCH] applyrules: fix potential false positive match

From: NRK <nrk_AT_disroot.org>
Date: Sat, 29 Oct 2022 16:59:23 +0600

if res_{class,name} is null, it is set to broken (which is just
"broken") to avoid calling strstr() with NULL.

but doing this can end up having false positive matches. so set them to
an empty string instead of "broken".
---
 dwm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c
index e5efb6a..0e32987 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -289,8 +289,8 @@ applyrules(Client *c)
 	c->isfloating = 0;
 	c->tags = 0;
 	XGetClassHint(dpy, c->win, &ch);
-	class    = ch.res_class ? ch.res_class : broken;
-	instance = ch.res_name  ? ch.res_name  : broken;
+	class    = ch.res_class ? ch.res_class : "";
+	instance = ch.res_name  ? ch.res_name  : "";
 
 	for (i = 0; i < LENGTH(rules); i++) {
 		r = &rules[i];
-- 
2.35.1
Received on Sat Oct 29 2022 - 12:59:23 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 29 2022 - 13:00:37 CEST