From e66c63b2ea52adef01c8b434ba14aae5c5c62208 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 7 Sep 2023 14:32:59 +0200 Subject: [PATCH] bpf: close fp in all error paths --- src/suricata.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/suricata.c b/src/suricata.c index 65fed9a07d..6b1a5b4d66 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -528,6 +528,7 @@ static void SetBpfStringFromFile(char *filename) if (SCFstatFn(fileno(fp), &st) != 0) { SCLogError(SC_ERR_FOPEN, "Failed to stat file %s", filename); + fclose(fp); exit(EXIT_FAILURE); } bpf_len = st.st_size + 1; @@ -535,6 +536,7 @@ static void SetBpfStringFromFile(char *filename) bpf_filter = SCMalloc(bpf_len * sizeof(char)); if (unlikely(bpf_filter == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate buffer for bpf filter in file %s", filename); + fclose(fp); exit(EXIT_FAILURE); } memset(bpf_filter, 0x00, bpf_len); -- 2.47.2