(svn r6884) -Codechange: Add strict bounds checking in string formatting system.

The last parameter should point to the end of the buffer (eg lastof(buf))
 Courtesy of Tron.
This commit is contained in:
Darkvater
2006-10-21 23:31:34 +00:00
parent 7f36a980c7
commit ee27bb497c
33 changed files with 240 additions and 231 deletions

View File

@@ -886,7 +886,7 @@ restart:
r = Random();
SetDParam(0, r);
GetString(buf1, townnametype);
GetString(buf1, townnametype, lastof(buf1));
// Check size and width
if (strlen(buf1) >= 31 || GetStringBoundingBox(buf1).width > 130) continue;
@@ -895,7 +895,7 @@ restart:
// We can't just compare the numbers since
// several numbers may map to a single name.
SetDParam(0, t2->index);
GetString(buf2, STR_TOWN);
GetString(buf2, STR_TOWN, lastof(buf2));
if (strcmp(buf1, buf2) == 0) {
if (tries-- < 0) return false;
goto restart;