Skip to content

Commit

Permalink
swtpm_setup: Return error if reading of config file failed
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stefanberger committed Sep 27, 2024
1 parent 2e42685 commit 2e21249
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/swtpm_setup/swtpm_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2e21249

Please sign in to comment.