Changeset - r8584:9141cb2fd096
[Not reviewed]
master
0 1 0
glx - 16 years ago 2008-02-17 00:47:39
glx@openttd.org
(svn r12165) -Fix [FS#1652, FS#1773]: buffer overflow when drawing scrolling news
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -1668,7 +1668,7 @@ static bool DrawScrollingStatusText(cons
 
{
 
	char buf[512];
 
	StringID str;
 
	const char *s;
 
	const char *s, *last;
 
	char *d;
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	int x;
 
@@ -1685,19 +1685,22 @@ static bool DrawScrollingStatusText(cons
 

	
 
	s = buf;
 
	d = buffer;
 
	last = lastof(buffer);
 

	
 
	for (;;) {
 
		WChar c = Utf8Consume(&s);
 
		if (c == 0) {
 
			*d = '\0';
 
			break;
 
		} else if (*s == 0x0D) {
 
		} else if (c == 0x0D) {
 
			if (d + 4 >= last) break;
 
			d[0] = d[1] = d[2] = d[3] = ' ';
 
			d += 4;
 
		} else if (IsPrintable(c)) {
 
			if (d + Utf8CharLen(c) >= last) break;
 
			d += Utf8Encode(d, c);
 
		}
 
	}
 
	*d = '\0';
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
 

	
0 comments (0 inline, 0 general)