Changeset - r9637:14bdab921c41
[Not reviewed]
master
0 1 0
rubidium - 16 years ago 2008-07-14 18:22:15
rubidium@openttd.org
(svn r13700) -Fix: possible buffer overflow in string truncation code.
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -256,9 +256,10 @@ static int TruncateString(char *str, int
 
			w += GetCharacterWidth(size, c);
 

	
 
			if (w >= maxw) {
 
				/* string got too big... insert dotdotdot */
 
				ddd_pos[0] = ddd_pos[1] = ddd_pos[2] = '.';
 
				ddd_pos[3] = '\0';
 
				/* string got too big... insert dotdotdot, but make sure we do not
 
				 * print anything beyond the string termination character. */
 
				for (int i = 0; *ddd_pos != '\0' && i < 3; i++, ddd_pos++) *ddd_pos = '.';
 
				*ddd_pos = '\0';
 
				return ddd_w;
 
			}
 
		} else {
0 comments (0 inline, 0 general)