discomfitor pushed a commit to branch master. http://git.enlightenment.org/core/enlightenment.git/commit/?id=53320330c608b7fcdb37a3400ba62794c2e09106
commit 53320330c608b7fcdb37a3400ba62794c2e09106 Author: Mike Blumenkrantz <zm...@osg.samsung.com> Date: Mon Apr 25 14:11:24 2016 -0400 protect xdg-shell functions from accessing deleted client data this is mostly an issue for internal windows since they get deleted by the compositor before the client is aware --- src/modules/wl_desktop_shell/e_mod_main.c | 68 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/modules/wl_desktop_shell/e_mod_main.c b/src/modules/wl_desktop_shell/e_mod_main.c index 539c02e..1064201 100644 --- a/src/modules/wl_desktop_shell/e_mod_main.c +++ b/src/modules/wl_desktop_shell/e_mod_main.c @@ -188,6 +188,7 @@ _e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resourc "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if ((ec->maximized) || (ec->fullscreen)) return; @@ -229,6 +230,7 @@ _e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resou "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if ((edges == 0) || (edges > 15) || ((edges & 3) == 3) || ((edges & 12) == 12)) return; @@ -279,6 +281,7 @@ _e_shell_surface_cb_toplevel_set(struct wl_client *client EINA_UNUSED, struct wl "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* set toplevel client properties */ if (!ec->internal) @@ -307,6 +310,7 @@ _e_shell_surface_cb_transient_set(struct wl_client *client EINA_UNUSED, struct w "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* set this client as a transient for parent */ _e_shell_surface_parent_set(ec, parent_resource); @@ -325,6 +329,7 @@ _e_shell_surface_cb_fullscreen_set(struct wl_client *client EINA_UNUSED, struct "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (!ec->lock_user_fullscreen) e_client_fullscreen(ec, e_config->fullscreen_policy); @@ -341,12 +346,10 @@ _e_shell_surface_cb_popup_set(struct wl_client *client EINA_UNUSED, struct wl_re "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; - if (ec->comp_data) - { - ec->comp_data->popup.x = x; - ec->comp_data->popup.y = y; - } + ec->comp_data->popup.x = x; + ec->comp_data->popup.y = y; if (!ec->internal) ec->borderless = !ec->internal_elm_win; @@ -379,6 +382,7 @@ _e_shell_surface_cb_maximized_set(struct wl_client *client EINA_UNUSED, struct w "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* tell E to maximize this client */ if (!ec->lock_user_maximize) @@ -406,6 +410,7 @@ _e_shell_surface_cb_title_set(struct wl_client *client EINA_UNUSED, struct wl_re "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* set title */ eina_stringshare_replace(&ec->icccm.title, title); @@ -425,6 +430,7 @@ _e_shell_surface_cb_class_set(struct wl_client *client EINA_UNUSED, struct wl_re "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* use the wl_client to get the pid * and set it in the netwm props */ wl_client_get_credentials(client, &ec->netwm.pid, NULL, NULL); @@ -471,6 +477,7 @@ _e_shell_surface_configure(struct wl_resource *resource, Evas_Coord x, Evas_Coor "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->parent) { @@ -506,6 +513,7 @@ _e_shell_surface_ping(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; serial = wl_display_next_serial(e_comp_wl->wl.disp); wl_shell_surface_send_ping(ec->comp_data->shell.surface, serial); @@ -524,6 +532,7 @@ _e_shell_surface_map(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* map this surface if needed */ if ((!ec->comp_data->mapped) && (e_pixmap_usable_get(ec->pixmap))) @@ -548,6 +557,7 @@ _e_shell_surface_unmap(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->comp_data->mapped) { @@ -571,15 +581,9 @@ _e_shell_cb_shell_surface_get(struct wl_client *client, struct wl_resource *reso "No Pixmap Set On Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; + cdata = ec->comp_data; ec->netwm.ping = 1; - /* get the client data */ - if (!(cdata = ec->comp_data)) - { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "No Data For Client"); - return; - } /* check for existing shell surface */ if (cdata->shell.surface) @@ -706,6 +710,7 @@ _e_xdg_shell_surface_configure_send(struct wl_resource *resource, uint32_t edges "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->netwm.type == E_WINDOW_TYPE_POPUP_MENU) return; _xdg_shell_surface_send_configure(resource, ec->fullscreen, !!ec->maximized, edges, ec->focused, width, height); @@ -728,6 +733,7 @@ _e_xdg_shell_surface_cb_parent_set(struct wl_client *client EINA_UNUSED, struct "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* set this client as a transient for parent */ _e_shell_surface_parent_set(ec, parent_resource); @@ -746,6 +752,7 @@ _e_xdg_shell_surface_cb_title_set(struct wl_client *client EINA_UNUSED, struct w "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* set title */ eina_stringshare_replace(&ec->icccm.title, title); @@ -765,6 +772,7 @@ _e_xdg_shell_surface_cb_app_id_set(struct wl_client *client EINA_UNUSED, struct "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; /* use the wl_client to get the pid * and set it in the netwm props */ wl_client_get_credentials(client, &ec->netwm.pid, NULL, NULL); @@ -790,6 +798,7 @@ _e_xdg_shell_surface_cb_window_menu_show(struct wl_client *client EINA_UNUSED, s "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; timestamp = ecore_loop_time_get(); e_int_client_menu_show(ec, x, y, 0, timestamp); @@ -809,6 +818,7 @@ _e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_res "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if ((ec->maximized) || (ec->fullscreen)) return; @@ -853,6 +863,7 @@ _e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_r "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if ((edges == 0) || (edges > 15) || ((edges & 3) == 3) || ((edges & 12) == 12)) return; @@ -902,6 +913,7 @@ _e_xdg_shell_surface_cb_ack_configure(struct wl_client *client EINA_UNUSED, stru "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; shd = ec->comp_data->shell.data; EINA_LIST_FREE(shd->pending, ps) { @@ -942,6 +954,7 @@ _e_xdg_shell_surface_cb_window_geometry_set(struct wl_client *client EINA_UNUSED "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; EINA_RECTANGLE_SET(&ec->comp_data->shell.window, x, y, w, h); //DBG("XDG_SHELL: Window Geom Set: %d \t%d %d, %d %d", wl_resource_get_id(resource), x, y, w, h); } @@ -960,6 +973,7 @@ _e_xdg_shell_surface_cb_maximized_set(struct wl_client *client EINA_UNUSED, stru "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->lock_user_maximize) return; if (e_config->window_maximize_animate && (!ec->maximize_anims_disabled)) @@ -992,6 +1006,7 @@ _e_xdg_shell_surface_cb_maximized_unset(struct wl_client *client EINA_UNUSED, st "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->lock_user_maximize) return; ec->comp_data->max = (e_config->maximize_policy & E_MAXIMIZE_TYPE) | E_MAXIMIZE_BOTH; @@ -1033,6 +1048,7 @@ _e_xdg_shell_surface_cb_fullscreen_unset(struct wl_client *client EINA_UNUSED, s "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->lock_user_fullscreen) return; _xdg_shell_surface_send_configure(resource, 0, ec->maximized, 0, ec->focused, ec->saved.w, ec->saved.h); @@ -1051,6 +1067,7 @@ _e_xdg_shell_surface_cb_minimized_set(struct wl_client *client EINA_UNUSED, stru "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->lock_user_iconify) return; ec->comp_data->shell.set.minimize = 1; @@ -1104,6 +1121,7 @@ _e_xdg_shell_surface_configure(struct wl_resource *resource, Evas_Coord x, Evas_ "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->parent) { @@ -1135,6 +1153,7 @@ _e_xdg_shell_surface_ping(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; client = wl_resource_get_client(resource); xdg_shell = eina_hash_find(xdg_shell_resources, &client); @@ -1158,6 +1177,7 @@ _e_xdg_shell_surface_map(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if ((!ec->comp_data->mapped) && (e_pixmap_usable_get(ec->pixmap))) { @@ -1188,6 +1208,7 @@ _e_xdg_shell_surface_unmap(struct wl_resource *resource) "No Client For Shell Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; if (ec->comp_data->mapped) { @@ -1213,17 +1234,10 @@ _e_xdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resour "No Pixmap Set On Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; ec->netwm.ping = 1; - - /* get the client data */ - if (!(cdata = ec->comp_data)) - { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "No Data For Client"); - return; - } + cdata = ec->comp_data; /* check for existing shell surface */ if (cdata->shell.surface) @@ -1302,15 +1316,9 @@ _e_xdg_shell_cb_popup_get(struct wl_client *client, struct wl_resource *resource "No Pixmap Set On Surface"); return; } + if (e_object_is_del(E_OBJECT(ec))) return; - /* get the client data */ - if (!(cdata = ec->comp_data)) - { - wl_resource_post_error(surface_resource, - WL_DISPLAY_ERROR_INVALID_OBJECT, - "No Data For Client"); - return; - } + cdata = ec->comp_data; /* check for existing shell surface */ if (cdata->shell.surface) --