>From 67b2c9c29b7eb9535645c07f65d3a885b801345c Mon Sep 17 00:00:00 2001 From: sin <s...@2f30.org> Date: Mon, 1 Dec 2014 20:08:02 +0000 Subject: [PATCH] Ensure buf[] is always null-terminated after strncpy()
Small style fix as well. --- lsw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lsw.c b/lsw.c index 9b01f6a..fc40fef 100644 --- a/lsw.c +++ b/lsw.c @@ -58,9 +58,9 @@ getname(Window win) { if(!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) { strncpy(buf, list[0], sizeof buf); XFreeStringList(list); - } - else + } else strncpy(buf, (char *)prop.value, sizeof buf); XFree(prop.value); + buf[sizeof buf - 1] = '\0'; return buf; } -- 1.8.4