Changeset - r20471:6814a0b87b95
[Not reviewed]
master
0 2 0
rubidium - 11 years ago 2013-06-27 19:23:23
rubidium@openttd.org
(svn r25486) -Fix [FS#5613-ish]: missing length validation for town and president names in script APIs
2 files changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_company.cpp
Show inline comments
 
@@ -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);
 
}
src/script/api/script_town.cpp
Show inline comments
 
@@ -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);
 
}
0 comments (0 inline, 0 general)