Run-time validation of INT settings.
Check against min/max/step parameters Many places this value is used as an index into an array; this will help prevent array overflows and undefined/undesireable behavior. Some fields accept arbitary values, continue to accept those. Change-Id: Idbb5a17b7ceae5500660987703e2d6c16e920c92
This commit is contained in:
parent
5c30d57ad1
commit
bf546fbfcb
1 changed files with 7 additions and 1 deletions
|
@ -311,7 +311,13 @@ bool settings_load_config(const char* file, bool apply)
|
||||||
#endif
|
#endif
|
||||||
if (settings[i].cfg_vals == NULL)
|
if (settings[i].cfg_vals == NULL)
|
||||||
{
|
{
|
||||||
*(int*)settings[i].setting = atoi(value);
|
if (settings[i].flags&F_ALLOW_ARBITRARY_VALS ||
|
||||||
|
(temp >= settings[i].int_setting->min &&
|
||||||
|
temp <= settings[i].int_setting->max &&
|
||||||
|
temp % settings[i].int_setting->step == 0))
|
||||||
|
{
|
||||||
|
*(int*)settings[i].setting = atoi(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue