]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
bpf: close fp in all error paths 9461/head 9472/head
authorVictor Julien <vjulien@oisf.net>
Thu, 7 Sep 2023 12:32:59 +0000 (14:32 +0200)
committerVictor Julien <vjulien@oisf.net>
Thu, 7 Sep 2023 19:15:38 +0000 (21:15 +0200)
src/suricata.c

index 65fed9a07d7a108ba577bdf880d0802be7f94cbb..6b1a5b4d667e10917ea98c107c6406cf9ea1dcc2 100644 (file)
@@ -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);