From 72a52454ada32ad06ece3d12f3ea61d9c940d951 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 8 Aug 2023 13:45:02 +0100 Subject: [PATCH] desktop-shell: Reject invalid focus types in configuration Just refuse to start up if someone passes an incorrect focus type. Signed-off-by: Daniel Stone --- desktop-shell/shell.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 6d0d12b2..61602e74 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -565,7 +565,7 @@ get_animation_type(char *animation) return ANIMATION_NONE; } -static void +static bool shell_configuration(struct desktop_shell *shell) { struct weston_config_section *section; @@ -592,15 +592,22 @@ shell_configuration(struct desktop_shell *shell) weston_config_section_get_string(section, "close-animation", &s, "fade"); shell->win_close_animation_type = get_animation_type(s); free(s); + weston_config_section_get_string(section, "startup-animation", &s, "fade"); shell->startup_animation_type = get_animation_type(s); + if (shell->startup_animation_type == ANIMATION_ZOOM) { + weston_log("invalid startup animation type %s\n", s); + free(s); + return false; + } free(s); - if (shell->startup_animation_type == ANIMATION_ZOOM) - shell->startup_animation_type = ANIMATION_NONE; + weston_config_section_get_string(section, "focus-animation", &s, "none"); shell->focus_animation_type = get_animation_type(s); free(s); + + return true; } static int @@ -5017,7 +5024,8 @@ wet_shell_init(struct weston_compositor *ec, shell->text_backend = text_backend_init(ec); - shell_configuration(shell); + if (!shell_configuration(shell)) + return -1; workspace_create(shell);