summaryrefslogtreecommitdiff
path: root/town_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-10-21 23:31:34 +0000
committerDarkvater <darkvater@openttd.org>2006-10-21 23:31:34 +0000
commitee27bb497c0790d86da6025fa48034f01f36d6e0 (patch)
treebbd2a7ac7e0c3b558bf638e1779108ced158cb6a /town_cmd.c
parent7f36a980c70d2444a68af5046e47c0313d67b2ef (diff)
downloadopenttd-ee27bb497c0790d86da6025fa48034f01f36d6e0.tar.xz
(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.
Diffstat (limited to 'town_cmd.c')
-rw-r--r--town_cmd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 981cdbfde..5ca064f9c 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -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;