From 4c4d9d6d5249f2fc35e05c71d01775b040198073 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 8 Nov 2020 10:30:49 -0600 Subject: wayland: fix buffer overrun in get_mods Use MP_ARRAY_SIZE and make the mod arrays here const. --- video/out/wayland_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'video/out/wayland_common.c') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index beb2a16316..38b9ca0a8c 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -127,21 +127,21 @@ static int set_cursor_visibility(struct vo_wayland_state *wl, bool on) static int get_mods(struct vo_wayland_state *wl) { - static const char *mod_names[] = { + static char* const mod_names[] = { XKB_MOD_NAME_SHIFT, XKB_MOD_NAME_CTRL, XKB_MOD_NAME_ALT, XKB_MOD_NAME_LOGO, }; - static int mods[] = { + static const int mods[] = { MP_KEY_MODIFIER_SHIFT, MP_KEY_MODIFIER_CTRL, MP_KEY_MODIFIER_ALT, MP_KEY_MODIFIER_META, }; - for (int n = 0; mods[n]; n++) { + for (int n = 0; n < MP_ARRAY_SIZE(mods); n++) { xkb_mod_index_t index = xkb_keymap_mod_get_index(wl->xkb_keymap, mod_names[n]); if (!xkb_state_mod_index_is_consumed(wl->xkb_state, wl->keyboard_code, index) && xkb_state_mod_index_is_active(wl->xkb_state, index, -- cgit v1.2.3