From 2e2124928f389e6eaa7da0d7ff796f45b0755dce Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Fri, 27 Sep 2024 13:03:19 -0400 Subject: [PATCH] swtpm_setup: Return error if reading of config file failed Return an error if the reading of the config file failed so that config_file_lines can never be NULL. Remove all checks for config_file_lines == NULL. It's very unlikely reading of the config file failed since there's a file access check right before it. Signed-off-by: Stefan Berger --- src/swtpm_setup/swtpm_setup.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/swtpm_setup/swtpm_setup.c b/src/swtpm_setup/swtpm_setup.c index 539158fd..d01dcd5d 100644 --- a/src/swtpm_setup/swtpm_setup.c +++ b/src/swtpm_setup/swtpm_setup.c @@ -477,9 +477,6 @@ static gchar *get_default_pcr_banks(gchar *const *config_file_lines) { gchar *pcr_banks; - if (!config_file_lines) - return NULL; - pcr_banks = get_config_value(config_file_lines, "active_pcr_banks"); if (pcr_banks) g_strstrip(pcr_banks); @@ -495,9 +492,6 @@ static gchar *get_default_rsa_keysize(gchar *const *config_file_lines) { gchar *rsa_keysize; - if (!config_file_lines) - return NULL; - rsa_keysize = get_config_value(config_file_lines, "rsa_keysize"); if (rsa_keysize) g_strstrip(rsa_keysize); @@ -1329,8 +1323,8 @@ static int read_config_file(const gchar *config_file, return -1; } - /* read the config file; ignore errors here now */ - read_file_lines(config_file, config_file_lines); + if (read_file_lines(config_file, config_file_lines)) + return -1; return 0; }