fixed a potential security flaw b8bccb4a
Anselm R. Garbe · 2007-05-10 13:47 1 file(s) · +5 −3
client.c +5 −3
365 365
		XGetWMName(dpy, c->win, &name);
366 366
	if(!name.nitems)
367 367
		return;
368 -
	if(name.encoding == XA_STRING)
369 -
		strncpy(c->name, (char *)name.value, sizeof c->name);
368 +
	if(name.encoding == XA_STRING) {
369 +
		strncpy(c->name, (char *)name.value, sizeof c->name - 1);
370 +
	}
370 371
	else {
371 372
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
372 373
		&& n > 0 && *list)
373 374
		{
374 -
			strncpy(c->name, *list, sizeof c->name);
375 +
			strncpy(c->name, *list, sizeof c->name - 1);
375 376
			XFreeStringList(list);
376 377
		}
377 378
	}
379 +
	c->name[sizeof c->name - 1] = '\0';
378 380
	XFree(name.value);
379 381
}
380 382