From: Michael Jerris Date: Thu, 23 Apr 2015 15:47:56 +0000 (-0500) Subject: CID:1271537: error check for malformed json better X-Git-Tag: v1.6.2~614^2~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7e811a62846069f9e99c28124bc70fc8e0415b2;p=thirdparty%2Ffreeswitch.git CID:1271537: error check for malformed json better --- diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index f94216471a..53cf751114 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -6468,24 +6468,29 @@ SWITCH_STANDARD_JSON_API(json_channel_data_function) SWITCH_STANDARD_JSON_API(json_execute_function) { - cJSON *reply, *data = cJSON_GetObjectItem(json, "data"); switch_status_t status = SWITCH_STATUS_FALSE; - const char *uuid = cJSON_GetObjectCstr(data, "uuid"); - const char *app = cJSON_GetObjectCstr(data, "app"); - const char *arg = cJSON_GetObjectCstr(data, "arg"); - const char *einline = cJSON_GetObjectCstr(data, "inline"); - const char *edata = cJSON_GetObjectCstr(data, "extendedData"); + cJSON *reply, *data = cJSON_GetObjectItem(json, "data"); + const char *uuid, *app, *arg, *einline, *edata; switch_core_session_t *tsession; - reply = cJSON_CreateObject(); *json_reply = reply; - if (!(uuid && app)) { + if (!data) { cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT")); goto end; } + uuid = cJSON_GetObjectCstr(data, "uuid"); + app = cJSON_GetObjectCstr(data, "app"); + arg = cJSON_GetObjectCstr(data, "arg"); + einline = cJSON_GetObjectCstr(data, "inline"); + edata = cJSON_GetObjectCstr(data, "extendedData"); + + if (!(uuid && app)) { + cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT")); + goto end; + } if ((tsession = switch_core_session_locate(uuid))) { if (switch_true(edata)) {