(svn r26206) -Fix [FS#5829]: Run everything from ini, obg, obs, obs, ... files through str_validate.

This commit is contained in:
frosch 2014-01-02 17:55:57 +00:00
parent 5156c3731b
commit e6f83028f6
2 changed files with 14 additions and 9 deletions

View File

@ -26,6 +26,8 @@ IniItem::IniItem(IniGroup *parent, const char *name, size_t len) : next(NULL), v
if (len == 0) len = strlen(name); if (len == 0) len = strlen(name);
this->name = strndup(name, len); this->name = strndup(name, len);
if (this->name != NULL) str_validate(this->name, this->name + len);
*parent->last_item = this; *parent->last_item = this;
parent->last_item = &this->next; parent->last_item = &this->next;
} }
@ -61,6 +63,8 @@ IniGroup::IniGroup(IniLoadFile *parent, const char *name, size_t len) : next(NUL
if (len == 0) len = strlen(name); if (len == 0) len = strlen(name);
this->name = strndup(name, len); this->name = strndup(name, len);
if (this->name != NULL) str_validate(this->name, this->name + len);
this->last_item = &this->item; this->last_item = &this->item;
*parent->last_group = this; *parent->last_group = this;
parent->last_group = &this->next; parent->last_group = &this->next;
@ -305,6 +309,7 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
/* If the value was not quoted and empty, it must be NULL */ /* If the value was not quoted and empty, it must be NULL */
item->value = (!quoted && e == t) ? NULL : strndup(t, e - t); item->value = (!quoted && e == t) ? NULL : strndup(t, e - t);
if (item->value != NULL) str_validate(item->value, item->value + strlen(item->value));
} else { } else {
/* it's an orphan item */ /* it's an orphan item */
this->ReportFileError("ini: '", buffer, "' outside of group"); this->ReportFileError("ini: '", buffer, "' outside of group");

View File

@ -29,7 +29,7 @@ static const char *_settings_profiles = "easy|medium|hard";
static const char *_news_display = "off|summarized|full"; static const char *_news_display = "off|summarized|full";
static const SettingDesc _gameopt_settings[] = { static const SettingDesc _gameopt_settings[] = {
/* In version 4 a new difficulty setting has been added to the difficulty 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 * 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 * it funny to have the GameDifficulty struct be an array while it is a struct of
* same-sized members * same-sized members