Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
bc38c935
Commit
bc38c935
authored
Jun 06, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: Check admin command table before use
parent
86154bc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
src/admin.c
src/admin.c
+21
-1
No files found.
src/admin.c
View file @
bc38c935
...
...
@@ -161,6 +161,17 @@ static admin_command_table_t command_tables[] = {
{.
prefix
=
NULL
,
.
length
=
(
sizeof
(
handlers
)
/
sizeof
(
*
handlers
)),
.
handlers
=
handlers
},
};
static
inline
int
__is_command_table_valid
(
const
admin_command_table_t
*
table
)
{
if
(
table
==
NULL
)
return
0
;
if
(
table
->
length
==
0
||
table
->
handlers
==
NULL
)
return
0
;
return
1
;
}
static
inline
const
admin_command_table_t
*
admin_get_table
(
admin_command_id_t
command
)
{
size_t
t
=
(
command
&
0x00FF0000
)
>>
16
;
...
...
@@ -168,6 +179,9 @@ static inline const admin_command_table_t * admin_get_table(admin_command_id_t c
if
(
t
>=
(
sizeof
(
command_tables
)
/
sizeof
(
*
command_tables
)))
return
NULL
;
if
(
!
__is_command_table_valid
(
&
(
command_tables
[
t
])))
return
NULL
;
return
&
(
command_tables
[
t
]);
}
...
...
@@ -181,7 +195,7 @@ static inline const admin_command_table_t * admin_get_table_by_prefix(const char
if
(
end
==
NULL
)
{
for
(
i
=
0
;
i
<
(
sizeof
(
command_tables
)
/
sizeof
(
*
command_tables
));
i
++
)
if
(
command_tables
[
i
].
prefix
==
NULL
)
if
(
command_tables
[
i
].
prefix
==
NULL
&&
__is_command_table_valid
(
&
(
command_tables
[
i
]))
)
return
&
(
command_tables
[
i
]);
return
NULL
;
...
...
@@ -190,6 +204,9 @@ static inline const admin_command_table_t * admin_get_table_by_prefix(const char
len
=
end
-
command
;
for
(
i
=
0
;
i
<
(
sizeof
(
command_tables
)
/
sizeof
(
*
command_tables
));
i
++
)
{
if
(
!
__is_command_table_valid
(
&
(
command_tables
[
i
])))
continue
;
if
(
command_tables
[
i
].
prefix
!=
NULL
&&
strlen
(
command_tables
[
i
].
prefix
)
==
len
&&
strncmp
(
command_tables
[
i
].
prefix
,
command
,
len
)
==
0
)
{
return
&
(
command_tables
[
i
]);
}
...
...
@@ -208,6 +225,9 @@ static inline admin_command_id_t admin_get_command_by_table_and_index(const admi
if
(
index
>
0x0FFFF
)
return
ADMIN_COMMAND_ERROR
;
if
(
!
__is_command_table_valid
(
table
))
return
ADMIN_COMMAND_ERROR
;
return
(
t
<<
16
)
|
index
;
}
...
...
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