Skip to content

Commit

Permalink
Fix segfault caused by non-null-terminated string.
Browse files Browse the repository at this point in the history
I got the printf %.*s idea from xcb documentation somewhere but now I
can't find it.

Fixes baskerville#1503
  • Loading branch information
falsifian committed Jul 19, 2024
1 parent b0ecf25 commit 1e77983
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 1e77983

Please sign in to comment.