]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/manager: fix prealloc unhandled division by 0 8624/head
authorJuliana Fajardini <jufajardini@oisf.net>
Mon, 20 Mar 2023 14:56:58 +0000 (11:56 -0300)
committerVictor Julien <vjulien@oisf.net>
Fri, 24 Mar 2023 05:28:55 +0000 (06:28 +0100)
If flow.prealloc was set to zero in our yaml config, this led to
a floating point exception in the flow manager.

Bug: #5919.

src/flow-manager.c

index dea1e87041119c36a202ec54aa9e26fab91104c2..1150031ffe40ecb7699eb53eb7b8376e01b4be6c 100644 (file)
@@ -814,7 +814,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);