aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-05-10 13:47:44 +0200
committerAnselm R. Garbe <arg@suckless.org>2007-05-10 13:47:44 +0200
commitb8bccb4ac5222a01ecd6a5f82997ea2ee3b84b8b (patch)
tree83c2aa1803f9a9948c2c8fd9b96bc3da91e57809
parentb6b2f584ecc0510acdf7e1df46ad397cff168335 (diff)
fixed a potential security flaw
-rw-r--r--client.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/client.c b/client.c
index 03d158f..64da343 100644
--- a/client.c
+++ b/client.c
@@ -365,16 +365,18 @@ updatetitle(Client *c) {
XGetWMName(dpy, c->win, &name);
if(!name.nitems)
return;
- if(name.encoding == XA_STRING)
- strncpy(c->name, (char *)name.value, sizeof c->name);
+ if(name.encoding == XA_STRING) {
+ strncpy(c->name, (char *)name.value, sizeof c->name - 1);
+ }
else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
&& n > 0 && *list)
{
- strncpy(c->name, *list, sizeof c->name);
+ strncpy(c->name, *list, sizeof c->name - 1);
XFreeStringList(list);
}
}
+ c->name[sizeof c->name - 1] = '\0';
XFree(name.value);
}