From: Victor Julien Date: Thu, 7 Sep 2023 12:32:59 +0000 (+0200) Subject: bpf: close fp in all error paths X-Git-Tag: suricata-6.0.14~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e66c63b2ea52adef01c8b434ba14aae5c5c62208;p=thirdparty%2Fsuricata.git bpf: close fp in all error paths --- 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);