From adc82cbe6ef430589bdcfdc26ab4a92d59319893 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 9 Jan 2012 13:53:17 -0600 Subject: [PATCH] fix some NULL pointer paths --- src/mod/applications/mod_httapi/mod_httapi.c | 37 +++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index e4947d1b59..ea6724037c 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -273,6 +273,11 @@ static switch_status_t parse_get_var(const char *tag_name, client_t *client, swi const char *var = switch_xml_attr(tag, "name"); const char *perm = switch_xml_attr(tag, "permanent"); + if (zstr(var)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing name attribute!"); + return SWITCH_STATUS_SUCCESS; + } + if (client->profile->perms.get_vars && (!client->profile->var_params.get_var_list || switch_event_check_permission_list(client->profile->var_params.get_var_list, var))) { @@ -692,32 +697,32 @@ static switch_status_t parse_execute(const char *tag_name, client_t *client, swi if (zstr(data)) data = body; + if (zstr(app_name)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid app\n"); + switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return SWITCH_STATUS_FALSE; + } + if (!check_app_perm(client, app_name)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Permission Denied!\n"); switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_STATUS_FALSE; } - if (zstr(app_name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid app\n"); - switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_FALSE; - } else { - if (!client->profile->perms.expand_vars) { - const char *p; - - for(p = data; p && *p; p++) { - if (*p == '$') { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Expand Variables: Permission Denied!\n"); - switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); - return SWITCH_STATUS_FALSE; - } + if (!client->profile->perms.expand_vars) { + const char *p; + + for(p = data; p && *p; p++) { + if (*p == '$') { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Expand Variables: Permission Denied!\n"); + switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + return SWITCH_STATUS_FALSE; } } - - switch_core_session_execute_application(client->session, app_name, data); } + switch_core_session_execute_application(client->session, app_name, data); + return SWITCH_STATUS_SUCCESS; }