Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7c5306a8
Commit
7c5306a8
authored
Jan 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/{Block,Global}: add missing strtoul() check
parent
201210cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
Block.cxx
src/config/Block.cxx
+6
-4
ConfigGlobal.cxx
src/config/ConfigGlobal.cxx
+6
-4
No files found.
src/config/Block.cxx
View file @
7c5306a8
...
...
@@ -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
;
...
...
src/config/ConfigGlobal.cxx
View file @
7c5306a8
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment