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
52e9cab1
Commit
52e9cab1
authored
Feb 14, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: check for empty string after strtol()
An empty string is obviously not a valid integer.
parent
1baaaa40
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
command.c
src/command.c
+7
-7
No files found.
src/command.c
View file @
52e9cab1
...
...
@@ -122,7 +122,7 @@ check_uint32(struct client *client, uint32_t *dst,
char
*
test
;
*
dst
=
strtoul
(
s
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
test
==
s
||
*
test
!=
'\0'
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
...
...
@@ -140,7 +140,7 @@ check_int(struct client *client, int *value_r,
long
value
;
value
=
strtol
(
s
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
test
==
s
||
*
test
!=
'\0'
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
...
...
@@ -168,7 +168,7 @@ check_range(struct client *client, unsigned *value_r1, unsigned *value_r2,
long
value
;
value
=
strtol
(
s
,
&
test
,
10
);
if
(
*
test
!=
'\0'
&&
*
test
!=
':'
)
{
if
(
test
==
s
||
(
*
test
!=
'\0'
&&
*
test
!=
':'
)
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
...
...
@@ -202,7 +202,7 @@ check_range(struct client *client, unsigned *value_r1, unsigned *value_r2,
if
(
*
test
==
':'
)
{
value
=
strtol
(
++
test
,
&
test2
,
10
);
if
(
*
test2
!=
'\0'
)
{
if
(
test2
==
test
||
*
test2
!=
'\0'
)
{
va_list
args
;
va_start
(
args
,
fmt
);
command_error_v
(
client
,
ACK_ERROR_ARG
,
fmt
,
args
);
...
...
@@ -241,7 +241,7 @@ check_unsigned(struct client *client, unsigned *value_r, const char *s)
char
*
endptr
;
value
=
strtoul
(
s
,
&
endptr
,
10
);
if
(
*
endptr
!=
0
)
{
if
(
endptr
==
s
||
*
endptr
!=
0
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Integer expected: %s"
,
s
);
return
false
;
...
...
@@ -264,7 +264,7 @@ check_bool(struct client *client, bool *value_r, const char *s)
char
*
endptr
;
value
=
strtol
(
s
,
&
endptr
,
10
);
if
(
*
endptr
!=
0
||
(
value
!=
0
&&
value
!=
1
))
{
if
(
endptr
==
s
||
*
endptr
!=
0
||
(
value
!=
0
&&
value
!=
1
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Boolean (0/1) expected: %s"
,
s
);
return
false
;
...
...
@@ -281,7 +281,7 @@ check_float(struct client *client, float *value_r, const char *s)
char
*
endptr
;
value
=
strtof
(
s
,
&
endptr
);
if
(
*
endptr
!=
0
&&
endptr
==
s
)
{
if
(
endptr
==
s
||
*
endptr
!=
0
)
{
command_error
(
client
,
ACK_ERROR_ARG
,
"Float expected: %s"
,
s
);
return
false
;
...
...
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