Mercurial > hg > openttd
changeset 20526:5e9fca24a4d3 draft
(svn r25486) -Fix [FS#5613-ish]: missing length validation for town and president names in script APIs
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 27 Jun 2013 19:23:23 +0000 |
parents | bcc571ddc72c |
children | 75d239e18307 |
files | src/script/api/script_company.cpp src/script/api/script_town.cpp |
diffstat | 2 files changed, 2 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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); }