summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorubba Smith <corubba@gmx.de>2025-03-08 23:32:29 +0100
committerFlorian Westphal <fw@strlen.de>2025-03-12 09:10:01 +0100
commit4c2a07b55d9e8a8366a1d3f5d04a2e6b971c0475 (patch)
treebdba8324d4e0918eb18750dc8af31dac67aa5465
parent33e19497f4ad88bcf08e10ac51c3ed091f60c9dc (diff)
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 <corubba@gmx.de> Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r--src/conffile.c10
1 files changed, 6 insertions, 4 deletions
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)))