]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: fix -Wshorten-64-to-32 warnings
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 17 Jul 2024 09:11:04 +0000 (11:11 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Fri, 19 Jul 2024 08:11:01 +0000 (10:11 +0200)
Ticket: #6186

src/defrag-config.c
src/defrag-config.h
src/defrag.c
src/defrag.h

index 1574a9367f6ce5694a691ce83bb6d09fce4ce9ba..23725dea3963a36ceae671fa59081e17d3d81acc 100644 (file)
@@ -124,7 +124,7 @@ static void DefragParseParameters(ConfNode *n)
     }
 }
 
-void DefragSetDefaultTimeout(intmax_t timeout)
+void DefragSetDefaultTimeout(int timeout)
 {
     default_timeout = timeout;
     SCLogDebug("default timeout %d", default_timeout);
index 2a0fb4e96469478231560482c5259fb905ff1e8e..e2b15dbb3167320123fb8a24df67ea8940f2122d 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "decode.h"
 
-void DefragSetDefaultTimeout(intmax_t timeout);
+void DefragSetDefaultTimeout(int timeout);
 void DefragPolicyLoadFromConfig(void);
 int DefragPolicyGetHostTimeout(Packet *p);
 void DefragTreeDestroy(void);
index 6d647d6cc5a3670e707811c3ae4ce6ca9eb0ff1c..eda41b76ccc110eac2aed7d5e64e9aa8b6baaaf2 100644 (file)
@@ -168,13 +168,13 @@ DefragContextNew(void)
 
     /* Initialize the pool of frags. */
     intmax_t frag_pool_size;
-    if (!ConfGetInt("defrag.max-frags", &frag_pool_size) || frag_pool_size == 0) {
+    if (!ConfGetInt("defrag.max-frags", &frag_pool_size) || frag_pool_size == 0 ||
+            frag_pool_size > UINT32_MAX) {
         frag_pool_size = DEFAULT_DEFRAG_POOL_SIZE;
     }
-    intmax_t frag_pool_prealloc = frag_pool_size / 2;
-    dc->frag_pool = PoolInit(frag_pool_size, frag_pool_prealloc,
-        sizeof(Frag),
-        NULL, DefragFragInit, dc, NULL, NULL);
+    uint32_t frag_pool_prealloc = (uint32_t)frag_pool_size / 2;
+    dc->frag_pool = PoolInit((uint32_t)frag_pool_size, frag_pool_prealloc, sizeof(Frag), NULL,
+            DefragFragInit, dc, NULL, NULL);
     if (dc->frag_pool == NULL) {
         FatalError("Defrag: Failed to initialize fragment pool.");
     }
@@ -194,7 +194,7 @@ DefragContextNew(void)
         else if (timeout > TIMEOUT_MAX) {
             FatalError("defrag: Timeout greater than maximum allowed value.");
         }
-        dc->timeout = timeout;
+        dc->timeout = (uint32_t)timeout;
     }
 
     SCLogDebug("Defrag Initialized:");
index 696b917cde8a1c28524ffb750fff371e85dfddfa..d118f026f75a27d53d17bd5d877ca03036cde908 100644 (file)
@@ -37,7 +37,7 @@ typedef struct DefragContext_ {
     Pool *frag_pool; /**< Pool of fragments. */
     SCMutex frag_pool_lock;
 
-    time_t timeout; /**< Default timeout. */
+    uint32_t timeout; /**< Default timeout. */
 } DefragContext;
 
 /**