From ac631853a8f63252492f6443867c505083b327b5 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 12 Apr 2022 13:30:32 -0400 Subject: [PATCH 1/3] client: Free command parser after event loop commit ed7b1690f0054888795059c2ef6ddd2f8107786a added an explicit command parser free call on exit to make memory analysis tools give better results. That commit freed the command parser a little too early, though, before the event loop gets freed and the event loop exit handlers are run. The command parser uses an exit handler to clear a weak reference on the event loop, so freeing the command parser before the event loop can lead to crash. This commit moves the free call a little lower. Related: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/175 --- src/client/plymouth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/plymouth.c b/src/client/plymouth.c index c2313368..4c95e688 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -1219,12 +1219,12 @@ main (int argc, exit_code = ply_event_loop_run (state.loop); out: - ply_command_parser_free (state.command_parser); - ply_boot_client_free (state.client); ply_event_loop_free (state.loop); + ply_command_parser_free (state.command_parser); + return exit_code; } /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ From a1996600ebb85f98c297fa47122b99fbdf49c6ea Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 12 Apr 2022 16:16:49 -0400 Subject: [PATCH 2/3] command-parser: Don't add duplicate command to command list ply_command_parser_get_options inexplicably adds a duplicate command to the list of available subcommands every time it's called. This must be some sort of cut and paste bug, it shouldn't be modifying the list. That leads to double frees when freeing the command parser. This commit fixes that. Related: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/175 --- src/libply/ply-command-parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libply/ply-command-parser.c b/src/libply/ply-command-parser.c index 4fec7fe2..c4cf1036 100644 --- a/src/libply/ply-command-parser.c +++ b/src/libply/ply-command-parser.c @@ -663,8 +663,6 @@ ply_command_parser_get_command_options (ply_command_parser_t *parser, va_start (args, option_name); ply_command_parser_get_options_for_command (parser, command, option_name, args); va_end (args); - - ply_list_append_data (parser->available_subcommands, command); } static void From 13799d9d8458d04bb0b6810a5ed99c70c3469d68 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 12 Apr 2022 17:23:14 -0400 Subject: [PATCH 3/3] script: Don't crash for scripts without input validation functions commit 5d1b49c601a085120e834c1e9134593318465eec adds support for filtering input to plymouthd and the script plugin. The script plugin additions, unfortunately, fail to properly handle scripts that don't add a validation function. This commit fixes that by assuming no validation function means no filtering. Closes: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/175 --- src/plugins/splash/script/script-lib-plymouth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/splash/script/script-lib-plymouth.c b/src/plugins/splash/script/script-lib-plymouth.c index 6be7199e..4848580e 100644 --- a/src/plugins/splash/script/script-lib-plymouth.c +++ b/src/plugins/splash/script/script-lib-plymouth.c @@ -387,6 +387,10 @@ bool script_lib_plymouth_on_validate_input (script_state_t *state, const char *add_text) { bool input_valid; + + if (script_obj_is_null (data->script_validate_input_func)) + return true; + script_obj_t *entry_text_obj = script_obj_new_string (entry_text); script_obj_t *add_text_obj = script_obj_new_string (add_text); script_return_t ret = script_execute_object (state,