Browse Source

fixed a potential security flaw

config
Anselm R. Garbe 17 years ago
parent
commit
b8bccb4ac5
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      client.c

+ 5
- 3
client.c View File

@ -365,16 +365,18 @@ updatetitle(Client *c) {
XGetWMName(dpy, c->win, &name); XGetWMName(dpy, c->win, &name);
if(!name.nitems) if(!name.nitems)
return; 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 { else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
&& n > 0 && *list) && n > 0 && *list)
{ {
strncpy(c->name, *list, sizeof c->name);
strncpy(c->name, *list, sizeof c->name - 1);
XFreeStringList(list); XFreeStringList(list);
} }
} }
c->name[sizeof c->name - 1] = '\0';
XFree(name.value); XFree(name.value);
} }


Loading…
Cancel
Save