From: Juliana Fajardini Date: Mon, 20 Mar 2023 14:56:58 +0000 (-0300) Subject: flow/manager: fix prealloc unhandled division by 0 X-Git-Tag: suricata-6.0.11~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2e863bfe8c91b16273cd5eefdf1b5e7d60d0fc4;p=thirdparty%2Fsuricata.git flow/manager: fix prealloc unhandled division by 0 If flow.prealloc was set to zero in our yaml config, this led to a floating point exception in the flow manager. Bug: #5919. (cherry picked from commit 5baa6c0024c7e49eb28e84546c286a5fd50fe303) --- diff --git a/src/flow-manager.c b/src/flow-manager.c index bb1e720fcb..e9b37c2948 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -822,7 +822,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) if (ts_ms >= next_run_ms) { if (ftd->instance == 0) { const uint32_t sq_len = FlowSpareGetPoolSize(); - const uint32_t spare_perc = sq_len * 100 / flow_config.prealloc; + const uint32_t spare_perc = sq_len * 100 / MAX(flow_config.prealloc, 1); /* see if we still have enough spare flows */ if (spare_perc < 90 || spare_perc > 110) { FlowSparePoolUpdate(sq_len);