mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-23 01:38:31 +00:00
FS-8537: Passing nil to various lua functions causes segfault
Various functions exposed via lua do not check their parameters for null causing freeswitch to segfault. This change adds checking for null parameters and returns an error instead of segfaulting.
This commit is contained in:
1 parent
de7a123c8b
commit
4e9977507d
4 files changed
+63
-18
No files matched your search
+24
-7
@@ -266,17 +266,24 @@ SWITCH_DECLARE(const char *) API::executeString(const char *cmd)
|
||||
|
||||
this_check("");
|
||||
|
||||
mycmd = strdup(cmd);
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
switch_assert(mycmd);
|
||||
if (zstr(cmd)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
|
||||
stream.write_function(&stream, "-ERR No application specified");
|
||||
} else {
|
||||
mycmd = strdup(cmd);
|
||||
|
||||
if ((arg = strchr(mycmd, ' '))) {
|
||||
*arg++ = '\0';
|
||||
switch_assert(mycmd);
|
||||
|
||||
if ((arg = strchr(mycmd, ' '))) {
|
||||
*arg++ = '\0';
|
||||
}
|
||||
|
||||
switch_api_execute(mycmd, arg, session, &stream);
|
||||
switch_safe_free(mycmd);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
switch_api_execute(mycmd, arg, session, &stream);
|
||||
switch_safe_free(mycmd);
|
||||
return (char *) stream.data;
|
||||
}
|
||||
|
||||
@@ -425,6 +432,11 @@ SWITCH_DECLARE(const char *)Event::getHeader(const char *header_name)
|
||||
{
|
||||
this_check("");
|
||||
|
||||
if (zstr(header_name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Trying to getHeader an invalid header!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
return switch_event_get_header(event, header_name);
|
||||
} else {
|
||||
@@ -450,6 +462,11 @@ SWITCH_DECLARE(bool) Event::delHeader(const char *header_name)
|
||||
{
|
||||
this_check(false);
|
||||
|
||||
if (zstr(header_name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Trying to delHeader an invalid header!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
return switch_event_del_header(event, header_name) == SWITCH_STATUS_SUCCESS ? true : false;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user