netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ulogd2 1/8] ulogd: fix config file fd leak
@ 2025-03-08 22:32 Corubba Smith
  2025-03-08 22:33 ` [PATCH ulogd2 2/8] ulogd: add ulogd_parse_configfile public function Corubba Smith
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Corubba Smith @ 2025-03-08 22:32 UTC (permalink / raw)
  To: netfilter-devel

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>
---
 src/conffile.c | 10 ++++++----
 1 file 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)))
--
2.48.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-12  7:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-08 22:32 [PATCH ulogd2 1/8] ulogd: fix config file fd leak Corubba Smith
2025-03-08 22:33 ` [PATCH ulogd2 2/8] ulogd: add ulogd_parse_configfile public function Corubba Smith
2025-03-12  7:47   ` Florian Westphal
2025-03-08 22:34 ` [PATCH ulogd2 3/8] all: use config_parse_file function in all plugins Corubba Smith
2025-03-08 22:35 ` [PATCH ulogd2 4/8] ulogd: raise error on unknown config key Corubba Smith
2025-03-08 22:36 ` [PATCH ulogd2 5/8] ulogd: ignore malformed config directives Corubba Smith
2025-03-08 22:37 ` [PATCH ulogd2 6/8] ulogd: improve integer option parsing Corubba Smith
2025-03-08 22:38 ` [PATCH ulogd2 7/8] ulogd: default configure implementation Corubba Smith
2025-03-08 22:39 ` [PATCH ulogd2 8/8] all: remove trivial configure hooks Corubba Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).