Improve security by using strlen(arg)+1 to prevent an insecure strncmp usage 17/316917/1 accepted/tizen/unified/20240902.161320 accepted/tizen/unified/dev/20240903.220515 accepted/tizen/unified/x/20240903.023130
authorduna.oh <duna.oh@samsung.com>
Fri, 30 Aug 2024 08:28:48 +0000 (17:28 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 30 Aug 2024 08:29:38 +0000 (17:29 +0900)
Change-Id: I08648d395a9309923af3c074a3e75b6b3952c1ec

src/e_mod_gesture_device.c

index 0146a671a40cd2c7411296c65e06c6112cea2c18..6846a57e9df8f2ec6b4d979fc367ad735f9161fd 100644 (file)
@@ -56,7 +56,7 @@ e_gesture_device_keydev_set(char *option)
         _e_gesture_device_keydev_create();
         gesture->device.kbd_name = strdup(E_GESTURE_KEYBOARD_NAME);
      }
-   else if (strncmp(option, "Any", sizeof("Any")))
+   else if (strncmp(option, "Any", sizeof("Any") + 1))
      {
         gesture->device.kbd_name = strdup(option);
      }
@@ -102,7 +102,7 @@ e_gesture_device_add(Ecore_Event_Device_Info *ev)
      {
         if (gesture->device.kbd_name)
           {
-             if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name)))
+             if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name) + 1))
                {
                   GTINF("%s(%s) device is key generated device in gesture\n", ev->name, ev->identifier);
                   gesture->device.kbd_identifier = strdup(ev->identifier);
@@ -130,7 +130,7 @@ e_gesture_device_del(Ecore_Event_Device_Info *ev)
      {
         EINA_LIST_FOREACH_SAFE(gesture->device.touch_devices, l, l_next, data)
           {
-             if (!strncmp(data, ev->identifier, strlen(ev->identifier)))
+             if (!strncmp(data, ev->identifier, strlen(ev->identifier) + 1))
                {
                   GTINF("%s(%s) device is touch device: remove list\n", ev->name, ev->identifier);
                   gesture->device.touch_devices = eina_list_remove(gesture->device.touch_devices, data);
@@ -141,7 +141,7 @@ e_gesture_device_del(Ecore_Event_Device_Info *ev)
    if ((gesture->device.kbd_identifier) &&
        (ev->clas == ECORE_DEVICE_CLASS_KEYBOARD))
      {
-        if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name)))
+        if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name) + 1))
           {
              GTWRN("Gesture keyboard device(%s) is disconnected. Gesture cannot create key events\n", gesture->device.kbd_name);
              E_FREE(gesture->device.kbd_identifier);