mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Update: Check admin command table before use
This commit is contained in:
parent
86154bc6d9
commit
bc38c93545
22
src/admin.c
22
src/admin.c
@ -161,6 +161,17 @@ static admin_command_table_t command_tables[] = {
|
|||||||
{.prefix = NULL, .length = (sizeof(handlers)/sizeof(*handlers)), .handlers = handlers},
|
{.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)
|
static inline const admin_command_table_t * admin_get_table(admin_command_id_t command)
|
||||||
{
|
{
|
||||||
size_t t = (command & 0x00FF0000) >> 16;
|
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)))
|
if (t >= (sizeof(command_tables)/sizeof(*command_tables)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (!__is_command_table_valid(&(command_tables[t])))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return &(command_tables[t]);
|
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) {
|
if (end == NULL) {
|
||||||
for (i = 0; i < (sizeof(command_tables)/sizeof(*command_tables)); i++)
|
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 &(command_tables[i]);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -190,6 +204,9 @@ static inline const admin_command_table_t * admin_get_table_by_prefix(const char
|
|||||||
len = end - command;
|
len = end - command;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(command_tables)/sizeof(*command_tables)); i++) {
|
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) {
|
if (command_tables[i].prefix != NULL && strlen(command_tables[i].prefix) == len && strncmp(command_tables[i].prefix, command, len) == 0) {
|
||||||
return &(command_tables[i]);
|
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)
|
if (index > 0x0FFFF)
|
||||||
return ADMIN_COMMAND_ERROR;
|
return ADMIN_COMMAND_ERROR;
|
||||||
|
|
||||||
|
if (!__is_command_table_valid(table))
|
||||||
|
return ADMIN_COMMAND_ERROR;
|
||||||
|
|
||||||
return (t << 16) | index;
|
return (t << 16) | index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user