[Spice-devel] [PATCH spice-gtk] vnc keymap: fix incorrect table size

Marc-André Lureau marcandre.lureau at gmail.com
Mon Oct 15 09:43:49 PDT 2012


This lead to out of bound array access
---
 gtk/vncdisplaykeymap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
index a6ef38c..bf79f9b 100644
--- a/gtk/vncdisplaykeymap.c
+++ b/gtk/vncdisplaykeymap.c
@@ -197,7 +197,7 @@ const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
 #ifdef GDK_WINDOWING_WIN32
 	if (GDK_IS_WIN32_DISPLAY(dpy)) {
 		VNC_DEBUG("Using Win32 virtual keycode mapping");
-		*maplen = sizeof(keymap_win322xtkbd);
+		*maplen = G_N_ELEMENTS(keymap_win322xtkbd);
 		return keymap_win322xtkbd;
 	}
 #endif
@@ -205,7 +205,7 @@ const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
 #ifdef GDK_WINDOWING_QUARTZ
 	if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
 		VNC_DEBUG("Using OS-X virtual keycode mapping");
-		*maplen = sizeof(keymap_osx2xtkbd);
+		*maplen = G_N_ELEMENTS(keymap_osx2xtkbd);
 		return keymap_osx2xtkbd;
 	}
 #endif
-- 
1.7.11.7



More information about the Spice-devel mailing list