]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
CID:1271537: error check for malformed json better
authorMichael Jerris <mike@jerris.com>
Thu, 23 Apr 2015 15:47:56 +0000 (10:47 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:25 +0000 (12:47 -0500)
src/mod/applications/mod_commands/mod_commands.c

index f94216471a3feea887489c665f5b2691af1aa588..53cf75111410360fc5bc0a4ef98262dedd6f1dfb 100644 (file)
@@ -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)) {