Wayland: Fix window titles being set to very long strings on the order of 8KB causing a crash

Fixes #1526
This commit is contained in:
Kovid Goyal 2020-01-27 08:49:25 +05:30
parent 109a856b91
commit 2e3037ce3a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 1 deletions

View File

@ -22,6 +22,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Wayland: Fix a freeze in rare circumstances when having multiple OS Windows - Wayland: Fix a freeze in rare circumstances when having multiple OS Windows
(:iss:`2307` and :iss:`1722`) (:iss:`2307` and :iss:`1722`)
- Wayland: Fix window titles being set to very long strings on the order of 8KB
causing a crash (:iss:`1526`)
- Add an option :opt:`force_ltr` to turn off the display of text in RTL scripts - Add an option :opt:`force_ltr` to turn off the display of text in RTL scripts
in right-to-left order (:pull:`2293`) in right-to-left order (:pull:`2293`)

6
glfw/wl_window.c vendored
View File

@ -958,8 +958,12 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
if (window->wl.title) if (window->wl.title)
free(window->wl.title); free(window->wl.title);
window->wl.title = _glfw_strdup(title); window->wl.title = _glfw_strdup(title);
// Wayland cannot handle requests larger than ~8200 bytes. Sending
// on causes an abort(). Since titles this large are meaningless anyway
// ensure they do not happen.
if (title && strnlen(title, 2048) >= 2048) window->wl.title[2048] = 0;
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
xdg_toplevel_set_title(window->wl.xdg.toplevel, title); xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
} }
void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED, void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED,