config/{Block,Global}: add missing strtoul() check
This commit is contained in:
parent
201210cfe1
commit
7c5306a841
@ -31,9 +31,10 @@
|
||||
int
|
||||
BlockParam::GetIntValue() const
|
||||
{
|
||||
const char *const s = value.c_str();
|
||||
char *endptr;
|
||||
long value2 = strtol(value.c_str(), &endptr, 0);
|
||||
if (*endptr != 0)
|
||||
long value2 = strtol(s, &endptr, 0);
|
||||
if (endptr == s || *endptr != 0)
|
||||
FormatFatalError("Not a valid number in line %i", line);
|
||||
|
||||
return value2;
|
||||
@ -42,9 +43,10 @@ BlockParam::GetIntValue() const
|
||||
unsigned
|
||||
BlockParam::GetUnsignedValue() const
|
||||
{
|
||||
const char *const s = value.c_str();
|
||||
char *endptr;
|
||||
unsigned long value2 = strtoul(value.c_str(), &endptr, 0);
|
||||
if (*endptr != 0)
|
||||
unsigned long value2 = strtoul(s, &endptr, 0);
|
||||
if (endptr == s || *endptr != 0)
|
||||
FormatFatalError("Not a valid number in line %i", line);
|
||||
|
||||
return (unsigned)value2;
|
||||
|
@ -140,8 +140,9 @@ config_get_unsigned(ConfigOption option, unsigned default_value)
|
||||
if (param == nullptr)
|
||||
return default_value;
|
||||
|
||||
value = strtol(param->value.c_str(), &endptr, 0);
|
||||
if (*endptr != 0 || value < 0)
|
||||
const char *const s = param->value.c_str();
|
||||
value = strtol(s, &endptr, 0);
|
||||
if (endptr == s || *endptr != 0 || value < 0)
|
||||
FormatFatalError("Not a valid non-negative number in line %i",
|
||||
param->line);
|
||||
|
||||
@ -158,8 +159,9 @@ config_get_positive(ConfigOption option, unsigned default_value)
|
||||
if (param == nullptr)
|
||||
return default_value;
|
||||
|
||||
value = strtol(param->value.c_str(), &endptr, 0);
|
||||
if (*endptr != 0)
|
||||
const char *const s = param->value.c_str();
|
||||
value = strtol(s, &endptr, 0);
|
||||
if (endptr == s || *endptr != 0)
|
||||
FormatFatalError("Not a valid number in line %i", param->line);
|
||||
|
||||
if (value <= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user