From: Anthony Minessale Date: Wed, 16 Sep 2015 03:35:29 +0000 (-0500) Subject: FS-8167 [mod_lua] Fixed a segfault caused by using api:execute or session:execute... X-Git-Tag: v1.4.23~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9936846e0198ec51ba9cba6d6917c7e345b9e8f1;p=thirdparty%2Ffreeswitch.git FS-8167 [mod_lua] Fixed a segfault caused by using api:execute or session:execute and not quoting the first argument like api:execute(log, “Second argument”) instead of api:execute(“log”, “Second argument”) --- diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 0404ba01aa..f861b80908 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -234,8 +234,16 @@ SWITCH_DECLARE(const char *) API::execute(const char *cmd, const char *arg) { switch_stream_handle_t stream = { 0 }; this_check(""); + SWITCH_STANDARD_STREAM(stream); - switch_api_execute(cmd, arg, session, &stream); + + 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 { + switch_api_execute(cmd, arg, session, &stream); + } + return (char *) stream.data; } @@ -730,6 +738,11 @@ SWITCH_DECLARE(void) CoreSession::execute(const char *app, const char *data) this_check_void(); sanity_check_noreturn; + if (zstr(app)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n"); + return; + } + begin_allow_threads(); switch_core_session_execute_application(session, app, data); end_allow_threads();