From 576f87afc2ac196c11fc14714f480c23cd8eb0e1 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Wed, 17 Jul 2024 11:14:31 +0200 Subject: [PATCH] suricata/bpf: fix -Wshorten-64-to-32 warnings Ticket: #6186 --- src/suricata.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/suricata.c b/src/suricata.c index 13b48fe91770..88bfb6323a95 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -520,7 +520,11 @@ static void SetBpfStringFromFile(char *filename) SCLogError("Failed to stat file %s", filename); exit(EXIT_FAILURE); } - bpf_len = st.st_size + 1; + if ((uint64_t)st.st_size > UINT32_MAX - 1) { + SCLogError("Too big file %s", filename); + exit(EXIT_FAILURE); + } + bpf_len = (uint32_t)(st.st_size + 1); bpf_filter = SCCalloc(1, bpf_len); if (unlikely(bpf_filter == NULL)) {