diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2014-08-25 15:55:22 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2014-08-26 13:04:08 +0200 |
commit | 8f2d8dfa3b3069c48b1c7cc82700e607d5c84e4e (patch) | |
tree | ee77c4296d8bd263a79441543e9090d2f672e822 /gdk/wayland/gdkkeys-wayland.c | |
parent | ab6f771413bb5a69c9be3365f0f899d5d318f73e (diff) | |
download | gtk+-8f2d8dfa3b3069c48b1c7cc82700e607d5c84e4e.tar.gz |
wayland: Protect against invalid keymaps gotten from the compositor
If the compositor sends a keymap that fails on "compilation",
xkb_keymap_new_from_string() returns NULL, which makes xkb_state_new()
crash when assuming there is a keymap.
In these cases, gdk must remain with a xkb_state to handle modifiers/keys
properly, so warn about the invalid keymap string, and keep the previous
keymap (currently initialized to "us")
https://bugzilla.gnome.org/show_bug.cgi?id=735389
Diffstat (limited to 'gdk/wayland/gdkkeys-wayland.c')
-rw-r--r-- | gdk/wayland/gdkkeys-wayland.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gdk/wayland/gdkkeys-wayland.c b/gdk/wayland/gdkkeys-wayland.c index 4e8e739cb9..d7341446c4 100644 --- a/gdk/wayland/gdkkeys-wayland.c +++ b/gdk/wayland/gdkkeys-wayland.c @@ -487,6 +487,7 @@ _gdk_wayland_keymap_update_from_fd (GdkKeymap *keymap, { GdkWaylandKeymap *keymap_wayland = GDK_WAYLAND_KEYMAP (keymap); struct xkb_context *context; + struct xkb_keymap *xkb_keymap; char *map_str; context = xkb_context_new (0); @@ -498,11 +499,20 @@ _gdk_wayland_keymap_update_from_fd (GdkKeymap *keymap, return; } - xkb_keymap_unref (keymap_wayland->xkb_keymap); - keymap_wayland->xkb_keymap = xkb_keymap_new_from_string (context, map_str, format, 0); + xkb_keymap = xkb_keymap_new_from_string (context, map_str, format, 0); munmap (map_str, size); close (fd); + if (!xkb_keymap) + { + g_warning ("Got invalid keymap from compositor, keeping previous/default one"); + xkb_context_unref (context); + return; + } + + xkb_keymap_unref (keymap_wayland->xkb_keymap); + keymap_wayland->xkb_keymap = xkb_keymap; + xkb_state_unref (keymap_wayland->xkb_state); keymap_wayland->xkb_state = xkb_state_new (keymap_wayland->xkb_keymap); |