summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-02-24 22:57:02 +0000
committersmatz <smatz@openttd.org>2009-02-24 22:57:02 +0000
commit13f390be3ecf2c13ae519ed008078ee1ab021206 (patch)
tree47c30f0f0e95eb2c81fc09230fda5e9ad1f106a8 /src
parent846044ee26f68875e8146fe2b00a45071bc66644 (diff)
downloadopenttd-13f390be3ecf2c13ae519ed008078ee1ab021206.tar.xz
(svn r15572) -Fix (r13730): theoretical buffer overflow when company with too long name funded a road reconstruction
Diffstat (limited to 'src')
-rw-r--r--src/town_cmd.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 6d043be4f..10d200ffd 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2197,15 +2197,15 @@ static void TownActionRoadRebuild(Town *t)
{
t->road_build_months = 6;
- char *company_name = MallocT<char>(64);
+ char company_name[MAX_LENGTH_COMPANY_NAME_BYTES];
SetDParam(0, _current_company);
- GetString(company_name, STR_COMPANY_NAME, company_name + 64);
+ GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
+ char *cn = strdup(company_name);
SetDParam(0, t->index);
- SetDParamStr(1, company_name);
+ SetDParamStr(1, cn);
- AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
- NS_GENERAL, t->xy, 0, company_name);
+ AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING, NS_GENERAL, t->xy, 0, cn);
}
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)