mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r25486) -Fix [FS#5613-ish]: missing length validation for town and president names in script APIs
This commit is contained in:
parent
928df8163a
commit
5d37e21d04
@ -66,6 +66,7 @@
|
|||||||
EnforcePrecondition(false, name != NULL);
|
EnforcePrecondition(false, name != NULL);
|
||||||
const char *text = name->GetEncodedText();
|
const char *text = name->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, text);
|
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);
|
return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
const char *encoded_text = text->GetEncodedText();
|
const char *encoded_text = text->GetEncodedText();
|
||||||
EnforcePreconditionEncodedText(false, encoded_text);
|
EnforcePreconditionEncodedText(false, encoded_text);
|
||||||
EnforcePrecondition(false, IsValidTown(town_id));
|
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);
|
return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user