summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Orth <ju.orth@gmail.com>2022-01-07 23:28:02 +0100
committerDudemanguy <random342@airmail.cc>2022-01-08 15:20:02 +0000
commit777628e7616f321709cc43c64c2ce0c79afced6b (patch)
treebf66d381710b365705d548594ac4a2ff36fbb985
parent3978669ece8bf2f5cb7318782607840195244368 (diff)
downloadmpv-777628e7616f321709cc43c64c2ce0c79afced6b.tar.bz2
mpv-777628e7616f321709cc43c64c2ce0c79afced6b.tar.xz
wayland: use `xkb_keymap_new_from_buffer`
Instead of `xkb_keymap_new_from_string`. The protocol does not require the keymap to be null terminated and if the size of the keymap is a multiple of the page size, using `_from_string` could lead to problems. Some compositors include a null byte and even include the null byte in `size`. Therefore we have to use `strnlen` to find the real length of the string. Note that `_from_string` internally uses `strlen` and then calls `_from_buffer`.
-rw-r--r--video/out/wayland_common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 226c94f7bc..ae657ec952 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -350,7 +350,8 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
return;
}
- wl->xkb_keymap = xkb_keymap_new_from_string(wl->xkb_context, map_str,
+ wl->xkb_keymap = xkb_keymap_new_from_buffer(wl->xkb_context, map_str,
+ strnlen(map_str, size),
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
munmap(map_str, size);