e_info: add validation checking code for calloc and enum range 31/141631/1
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 21 Jul 2017 04:06:41 +0000 (13:06 +0900)
committerJunSeok Kim <juns.kim@samsung.com>
Tue, 1 Aug 2017 07:18:43 +0000 (07:18 +0000)
Change-Id: I9e972d02233a98ec5559e4b79112d086a3acfebf
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
(cherry picked from commit 44bf51a3fe2b9b8fcb652c4d244e8bed3d06ad8f)

src/bin/e_info_client.c
src/bin/e_info_server.c

index 31ad8edca991852880be21a05c8b1046c69324a5..7eca6b222ab1a0f00231bfa39b8915661b4f4d3a 100644 (file)
@@ -680,7 +680,7 @@ _cb_input_device_info_get(const Eldbus_Message *msg)
    const char *name = NULL, *text = NULL;
    Eldbus_Message_Iter *array, *eldbus_msg;
    Eina_Bool res;
-   E_Comp_Wl_Input_Device *dev;
+   E_Comp_Wl_Input_Device *dev = NULL;
 
    res = eldbus_message_error_get(msg, &name, &text);
    EINA_SAFETY_ON_TRUE_GOTO(res, finish);
@@ -705,6 +705,8 @@ _cb_input_device_info_get(const Eldbus_Message *msg)
           }
 
         dev = E_NEW(E_Comp_Wl_Input_Device, 1);
+        EINA_SAFETY_ON_NULL_GOTO(dev, finish);
+
         dev->name = strdup(dev_name);
         dev->identifier = strdup(identifier);
         dev->clas = clas;
@@ -890,6 +892,8 @@ _e_info_client_proc_protocol_rule(int argc, char **argv)
    if (new_argc < 2)
      {
         new_s1 = (char *)calloc (1, PATH_MAX);
+        EINA_SAFETY_ON_NULL_RETURN(new_s1);
+
         snprintf(new_s1, PATH_MAX, "%s", "no_data");
         new_argv[1] = new_s1;
         new_argc++;
@@ -897,6 +901,8 @@ _e_info_client_proc_protocol_rule(int argc, char **argv)
    if (new_argc < 3)
      {
         new_s2 = (char *)calloc (1, PATH_MAX);
+        EINA_SAFETY_ON_NULL_GOTO(new_s2, finish);
+
         snprintf(new_s2, PATH_MAX, "%s", "no_data");
         new_argv[2] = new_s2;
         new_argc++;
@@ -904,11 +910,12 @@ _e_info_client_proc_protocol_rule(int argc, char **argv)
    if (new_argc != 3)
      {
         printf("protocol-trace: Usage> enlightenment_info -protocol_rule [add | remove | print | help] [allow/deny/all]\n");
-        return;
+        goto finish;
      }
 
    _e_info_client_eldbus_message_with_args("protocol_rule", _cb_protocol_rule, "sss", new_argv[0], new_argv[1], new_argv[2]);
 
+finish:
    if (new_s1) free(new_s1);
    if (new_s2) free(new_s2);
 }
index 85fbcdf1837201b8298b617b4bc929e80c8694fe..94e1f2fd27b20eeed223ee4bb94255d2d4853c86 100644 (file)
@@ -188,7 +188,7 @@ e_info_server_hook_del(E_Info_Server_Hook *iswh)
 E_API void
 e_info_server_hook_call(E_Info_Server_Hook_Point hookpoint)
 {
-   if ((hookpoint < 0) || (hookpoint >= E_INFO_SERVER_HOOK_LAST)) return;
+   if (hookpoint >= E_INFO_SERVER_HOOK_LAST) return;
 
    _e_info_server_hook_call(hookpoint, NULL);
 }
@@ -332,6 +332,8 @@ static Obj_Info *
 _obj_info_get(Evas_Object *po, Evas_Object *o, int depth)
 {
    Obj_Info *info = E_NEW(Obj_Info, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(info, NULL);
+
    info->po = po;
    info->o = o;
    info->depth = depth;
@@ -352,6 +354,7 @@ _compobj_info_get(Evas_Object *po, Evas_Object *o, int depth)
    Evas_Native_Surface *ns;
 
    cobj = E_NEW(E_Info_Comp_Obj, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(cobj, NULL);
 
    cobj->obj = (unsigned int)o;
    cobj->depth = depth;
@@ -550,6 +553,7 @@ _e_info_server_cb_compobjs(const Eldbus_Service_Interface *iface EINA_UNUSED, co
    for (o = evas_object_bottom_get(e_comp->evas); o; o = evas_object_above_get(o))
      {
         info = _obj_info_get(NULL, o, 0);
+        if (!info) continue;
         stack = eina_list_append(stack, info);
      }
 
@@ -561,6 +565,7 @@ _e_info_server_cb_compobjs(const Eldbus_Service_Interface *iface EINA_UNUSED, co
 
         /* store data */
         cobj = _compobj_info_get(info->po, info->o, info->depth);
+        if (!cobj) continue;
         queue = eina_list_append(queue, cobj);
 
         /* 3. push : child objects */