From: duna.oh Date: Wed, 16 Aug 2023 10:56:27 +0000 (+0900) Subject: e_keyrouter: check validation of key when unsetting keygrab X-Git-Tag: accepted/tizen/unified/20230818.054611^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2b1d63ed531a2db827ffddf525caa82dcad7359;p=platform%2Fupstream%2Fenlightenment.git e_keyrouter: check validation of key when unsetting keygrab Change-Id: Ibe190b58eee3b85da41f6d689aee8712884ac721 --- diff --git a/src/bin/e_keyrouter_list.c b/src/bin/e_keyrouter_list.c index f64f1289ce..bf99aa357b 100644 --- a/src/bin/e_keyrouter_list.c +++ b/src/bin/e_keyrouter_list.c @@ -473,7 +473,7 @@ e_keyrouter_keygrab_set(struct wl_client *client, struct wl_resource *surface, i /* Check the given key range */ if (krt->max_tizen_hwkeys < key) { - KLWRN("Invalid range of key ! (keycode:%d)", key); + KLWRN("Invalid range of key ! (keycode:%d) maximum value(%d)", key, krt->max_tizen_hwkeys); return TIZEN_KEYROUTER_ERROR_INVALID_KEY; } @@ -481,7 +481,7 @@ e_keyrouter_keygrab_set(struct wl_client *client, struct wl_resource *surface, i * Only key listed in Tizen key layout file can be grabbed. */ if (0 == krt->HardKeys[key].keycode) { - KLWRN("Invalid key ! Disabled to grab ! (keycode:%d)", key); + KLWRN("Invalid key ! Disabled to set keygrab ! (keycode:%d)", key); return TIZEN_KEYROUTER_ERROR_INVALID_KEY; } @@ -494,6 +494,22 @@ e_keyrouter_keygrab_set(struct wl_client *client, struct wl_resource *surface, i int e_keyrouter_keygrab_unset(struct wl_client *client, struct wl_resource *surface, int key) { + + /* Check the given key range */ + if (krt->max_tizen_hwkeys < key) + { + KLWRN("Invalid range of key ! (keycode:%d) maximum value(%d)", key, krt->max_tizen_hwkeys); + return TIZEN_KEYROUTER_ERROR_INVALID_KEY; + } + + /* Check whether the key can be unset or not ! + * Only key listed in Tizen key layout file can be unset. */ + if (0 == krt->HardKeys[key].keycode) + { + KLWRN("Invalid key ! Disabled to unset keygrab! (keycode:%d)", key); + return TIZEN_KEYROUTER_ERROR_INVALID_KEY; + } + /* Ungrab top position grabs first. This grab mode do not need privilege */ if (!surface) e_keyrouter_find_and_remove_client_from_list(NULL, client, key, TIZEN_KEYROUTER_MODE_TOPMOST);