(svn r13700) -Fix: possible buffer overflow in string truncation code.

pull/155/head
rubidium 16 years ago
parent f6ab930cc0
commit 42d0500f40

@ -256,9 +256,10 @@ static int TruncateString(char *str, int maxw)
w += GetCharacterWidth(size, c); w += GetCharacterWidth(size, c);
if (w >= maxw) { if (w >= maxw) {
/* string got too big... insert dotdotdot */ /* string got too big... insert dotdotdot, but make sure we do not
ddd_pos[0] = ddd_pos[1] = ddd_pos[2] = '.'; * print anything beyond the string termination character. */
ddd_pos[3] = '\0'; for (int i = 0; *ddd_pos != '\0' && i < 3; i++, ddd_pos++) *ddd_pos = '.';
*ddd_pos = '\0';
return ddd_w; return ddd_w;
} }
} else { } else {

Loading…
Cancel
Save