From c44225f3732f294ab8ad056e92982c98abc5ade8 Mon Sep 17 00:00:00 2001 From: James Cook Date: Fri, 19 Jul 2024 17:20:13 +0000 Subject: [PATCH] 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 b7e55aac..2bf41e81 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); } }