[hackers] [dwm] [PATCH] add a comment to clarify a potential overflow of ltsymbol

From: Tom Schwindl <schwindl_AT_posteo.de>
Date: Wed, 15 Feb 2023 11:29:26 +0000

In case the strncpy() call is advised to copy >=16 characters, ltsymbol overflows.
As dwm does not expect to have a ltsymbol bigger than 15 characters, there will be
no length check[0]. Our target audience are programmers, they should be able
to figure out how to extend the length by themselves. The reason to add this comment
is that some inexperienced users are easily confused by this and the topic comes up
from time to time[1].

[0] https://lists.suckless.org/hackers/2208/18484.html
[1] https://lists.suckless.org/dev/2210/35000.html

I know that this patch looks like bikeshedding, but the comment is convenient.
I also got messaged in private a few(!) times about that exact issue, but
I'm not sure if I'm allowed to quote these mails here. Anyways, the point is
that this issue arises from time to time and a comment would make our/their
lifes easier.
 dwm.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/dwm.c b/dwm.c
index c2bd8710544e..e400aa028587 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -396,6 +396,9 @@ arrange(Monitor *m)
 arrangemon(Monitor *m)
+	/* dwm supports a ltsymbol size up to 15 chars (plus terminating NUL-byte).
+	 * Anything greater than that will cause issues. If the user wants a name
+	 * containing more chars, they need to modify the code to fit their needs */
 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
 	if (m->lt[m->sellt]->arrange)
Received on Wed Feb 15 2023 - 12:29:26 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 15 2023 - 12:36:41 CET