Changeset - r21121:652ccbb04bc8
[Not reviewed]
master
0 2 0
frosch - 11 years ago 2014-01-02 17:55:57
frosch@openttd.org
(svn r26206) -Fix [FS#5829]: Run everything from ini, obg, obs, obs, ... files through str_validate.
2 files changed with 14 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/ini_load.cpp
Show inline comments
 
@@ -23,12 +23,14 @@
 
 */
 
IniItem::IniItem(IniGroup *parent, const char *name, size_t len) : next(NULL), value(NULL), comment(NULL)
 
{
 
	if (len == 0) len = strlen(name);
 

	
 
	this->name = strndup(name, len);
 
	if (this->name != NULL) str_validate(this->name, this->name + len);
 

	
 
	*parent->last_item = this;
 
	parent->last_item = &this->next;
 
}
 

	
 
/** Free everything we loaded. */
 
IniItem::~IniItem()
 
@@ -58,12 +60,14 @@ void IniItem::SetValue(const char *value
 
 */
 
IniGroup::IniGroup(IniLoadFile *parent, const char *name, size_t len) : next(NULL), type(IGT_VARIABLES), item(NULL), comment(NULL)
 
{
 
	if (len == 0) len = strlen(name);
 

	
 
	this->name = strndup(name, len);
 
	if (this->name != NULL) str_validate(this->name, this->name + len);
 

	
 
	this->last_item = &this->item;
 
	*parent->last_group = this;
 
	parent->last_group = &this->next;
 

	
 
	if (parent->list_group_names != NULL) {
 
		for (uint i = 0; parent->list_group_names[i] != NULL; i++) {
 
@@ -302,12 +306,13 @@ void IniLoadFile::LoadFromDisk(const cha
 
			e = t + strlen(t);
 
			if (e > t && e[-1] == '\"') e--;
 
			*e = '\0';
 

	
 
			/* If the value was not quoted and empty, it must be NULL */
 
			item->value = (!quoted && e == t) ? NULL : strndup(t, e - t);
 
			if (item->value != NULL) str_validate(item->value, item->value + strlen(item->value));
 
		} else {
 
			/* it's an orphan item */
 
			this->ReportFileError("ini: '", buffer, "' outside of group");
 
		}
 
	}
 

	
src/table/gameopt_settings.ini
Show inline comments
 
@@ -26,21 +26,21 @@ static const char *_server_langs = "ANY|
 
#endif /* ENABLE_NETWORK */
 
static const char *_osk_activation = "disabled|double|single|immediately";
 
static const char *_settings_profiles = "easy|medium|hard";
 
static const char *_news_display = "off|summarized|full";
 

	
 
static const SettingDesc _gameopt_settings[] = {
 
	/* In version 4 a new difficulty setting has been added to the difficulty settings,
 
	 * town attitude towards demolishing. Needs special handling because some dimwit thought
 
	 * it funny to have the GameDifficulty struct be an array while it is a struct of
 
	 * same-sized members
 
	 * XXX - To save file-space and since values are never bigger than about 10? only
 
	 * save the first 16 bits in the savegame. Question is why the values are still int32
 
	 * and why not byte for example?
 
	 * 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
 
	 * for savegames version 0 - though it is an array, it has to go through the byteswap process */
 
/* In version 4 a new difficulty setting has been added to the difficulty settings,
 
 * town attitude towards demolishing. Needs special handling because some dimwit thought
 
 * it funny to have the GameDifficulty struct be an array while it is a struct of
 
 * same-sized members
 
 * XXX - To save file-space and since values are never bigger than about 10? only
 
 * save the first 16 bits in the savegame. Question is why the values are still int32
 
 * and why not byte for example?
 
 * 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
 
 * for savegames version 0 - though it is an array, it has to go through the byteswap process */
 
[post-amble]
 
};
 
[templates]
 
SDTG_GENERAL = SDTG_GENERAL($name, $sdt_cmd, $sle_cmd, $type, $flags, $guiflags, $var, $length, $def, $min, $max, $interval, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat),
 
SDTG_VAR     =     SDTG_VAR($name,                     $type, $flags, $guiflags, $var,          $def, $min, $max, $interval,        $str, $strhelp, $strval, $proc, $from, $to, $cat),
 
SDT_NULL     =   SDT_NULL($length, $from, $to),
0 comments (0 inline, 0 general)