summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-27 19:23:23 +0000
committerrubidium <rubidium@openttd.org>2013-06-27 19:23:23 +0000
commit5d37e21d04391ab985744aff9ccb4e159d27d82d (patch)
tree4a0ae179e69e3d0d9dbfdcd7eab0497916ce5375 /src/script
parent928df8163afec53678de98ddee71f5bb2a0e4fed (diff)
downloadopenttd-5d37e21d04391ab985744aff9ccb4e159d27d82d.tar.xz
(svn r25486) -Fix [FS#5613-ish]: missing length validation for town and president names in script APIs
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_company.cpp1
-rw-r--r--src/script/api/script_town.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index 8dea4c22e..99fe34376 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -66,6 +66,7 @@
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
EnforcePreconditionEncodedText(false, text);
+ EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_PRESIDENT_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text);
}
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index fa4b9c0c7..5ade6f40f 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -46,6 +46,7 @@
const char *encoded_text = text->GetEncodedText();
EnforcePreconditionEncodedText(false, encoded_text);
EnforcePrecondition(false, IsValidTown(town_id));
+ EnforcePreconditionCustomError(false, ::Utf8StringLength(encoded_text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
}