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 <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2024-09-27 13:03:19 -04:00 committed by Stefan Berger
parent 2e42685e6d
commit 2e2124928f

View File

@ -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;
}