From 4c2a07b55d9e8a8366a1d3f5d04a2e6b971c0475 Mon Sep 17 00:00:00 2001 From: Corubba Smith Date: Sat, 8 Mar 2025 23:32:29 +0100 Subject: ulogd: fix config file fd leak Consistently use the return jump to close the config file descriptor if opened, to prevent it from leaking. Signed-off-by: Corubba Smith Signed-off-by: Florian Westphal --- src/conffile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/conffile.c b/src/conffile.c index 66769de..5b7f834 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -143,7 +143,8 @@ int config_parse_file(const char *section, struct config_keyset *kset) /* if line was fetch completely, string ends with '\n' */ if (! strchr(line, '\n')) { ulogd_log(ULOGD_ERROR, "line %d too long.\n", linenum); - return -ERRTOOLONG; + err = -ERRTOOLONG; + goto cpf_error; } if (!(wordend = get_word(line, " \t\n\r[]", (char *) wordbuf))) @@ -156,8 +157,8 @@ int config_parse_file(const char *section, struct config_keyset *kset) } if (!found) { - fclose(cfile); - return -ERRSECTION; + err = -ERRSECTION; + goto cpf_error; } /* Parse this section until next section */ @@ -175,7 +176,8 @@ int config_parse_file(const char *section, struct config_keyset *kset) /* if line was fetch completely, string ends with '\n' */ if (! strchr(line, '\n')) { ulogd_log(ULOGD_ERROR, "line %d too long.\n", linenum); - return -ERRTOOLONG; + err = -ERRTOOLONG; + goto cpf_error; } if (!(wordend = get_word(line, " =\t\n\r", (char *) &wordbuf))) -- cgit v1.2.3