From: Corubba Smith Date: Sat, 8 Mar 2025 22:32:29 +0000 (+0100) Subject: ulogd: fix config file fd leak X-Git-Tag: ulogd-2.0.9~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c2a07b55d9e8a8366a1d3f5d04a2e6b971c0475;p=thirdparty%2Fulogd2.git 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 --- 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)))