summaryrefslogtreecommitdiff
path: root/bspwm/0003-Fix-segfault-caused-by-non-null-terminated-string.patch
blob: edec54edc790775d3f3567f6231bfa8841b57245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From c631b202ab85267759fa875db11e0fa6b0324eaf Mon Sep 17 00:00:00 2001
From: James Cook <falsifian@falsifian.org>
Date: Fri, 19 Jul 2024 17:20:13 +0000
Subject: [PATCH 3/3] Fix segfault caused by non-null-terminated string.

I got the printf %.*s idea from xcb documentation somewhere but now I
can't find it.

Fixes #1503
---
 src/rule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rule.c b/src/rule.c
index b7e55aa..2bf41e8 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -307,7 +307,7 @@ void _apply_name(xcb_window_t win, rule_consequence_t *csq)
 {
 	xcb_icccm_get_text_property_reply_t reply;
 	if (xcb_icccm_get_wm_name_reply(dpy, xcb_icccm_get_wm_name(dpy, win), &reply, NULL) == 1) {
-		snprintf(csq->name, sizeof(csq->name), "%s", reply.name);
+		snprintf(csq->name, sizeof(csq->name), "%.*s", reply.name_len, reply.name);
 		xcb_icccm_get_text_property_reply_wipe(&reply);
 	}
 }
-- 
2.47.1