]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
suricata/bpf: fix -Wshorten-64-to-32 warning 12096/head
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 4 Nov 2024 16:09:32 +0000 (17:09 +0100)
committerPhilippe Antoine <pantoine@oisf.net>
Thu, 7 Nov 2024 15:04:45 +0000 (16:04 +0100)
Ticket: 7366
Ticket: 6186
(cherry picked from commit dd71ef0af222a566e54dfc479dd1951dd17d7ceb)

src/suricata.c

index 5c8c7cfafeedb7c3fef1ae9292f59c06a52ce373..70b4dfae86938cbcb7cce810ee38d80f791e40da 100644 (file)
@@ -503,7 +503,7 @@ static void SetBpfStringFromFile(char *filename)
     char *bpf_filter = NULL;
     char *bpf_comment_tmp = NULL;
     char *bpf_comment_start =  NULL;
-    uint32_t bpf_len = 0;
+    size_t bpf_len = 0;
     SCStat st;
     FILE *fp = NULL;
     size_t nm = 0;
@@ -518,7 +518,8 @@ static void SetBpfStringFromFile(char *filename)
         SCLogError("Failed to stat file %s", filename);
         exit(EXIT_FAILURE);
     }
-    bpf_len = st.st_size + 1;
+    // st.st_size is signed on Windows
+    bpf_len = ((size_t)(st.st_size)) + 1;
 
     bpf_filter = SCMalloc(bpf_len);
     if (unlikely(bpf_filter == NULL)) {