From: Philippe Antoine Date: Wed, 17 Jul 2024 09:11:04 +0000 (+0200) Subject: defrag: fix -Wshorten-64-to-32 warnings X-Git-Tag: suricata-8.0.0-beta1~994 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce2c087e92ea68cffd63061a7a1afc4ceb76c68e;p=thirdparty%2Fsuricata.git defrag: fix -Wshorten-64-to-32 warnings Ticket: #6186 --- diff --git a/src/defrag-config.c b/src/defrag-config.c index 1574a9367f..23725dea39 100644 --- a/src/defrag-config.c +++ b/src/defrag-config.c @@ -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); diff --git a/src/defrag-config.h b/src/defrag-config.h index 2a0fb4e964..e2b15dbb31 100644 --- a/src/defrag-config.h +++ b/src/defrag-config.h @@ -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); diff --git a/src/defrag.c b/src/defrag.c index 6d647d6cc5..eda41b76cc 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -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:"); diff --git a/src/defrag.h b/src/defrag.h index 696b917cde..d118f026f7 100644 --- a/src/defrag.h +++ b/src/defrag.h @@ -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; /**