diff mbox series

[ovs-dev,2/4] northd: Fix potential overflow

Message ID 20240626133007.694177-3-amusil@redhat.com
State Accepted
Headers show
Series Fix issues reported by coverity | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ales Musil June 26, 2024, 1:30 p.m. UTC
The threshold computation could overflow during the conversion to ms.
Make sure that the arithmetic is done on 64-bit value instead of
32-bit one.

Signed-off-by: Ales Musil <amusil@redhat.com>
---
 northd/aging.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/northd/aging.c b/northd/aging.c
index 9685044e7..e095f29b2 100644
--- a/northd/aging.c
+++ b/northd/aging.c
@@ -330,7 +330,8 @@  aging_context_handle_timestamp(struct aging_context *ctx, int64_t timestamp,
     }
 
     ovs_assert(ctx->threshold);
-    uint64_t threshold = 1000 * find_threshold_for_ip(ip, ctx->threshold);
+    uint64_t threshold =
+            1000 * (uint64_t) find_threshold_for_ip(ip, ctx->threshold);
 
     if (!threshold) {
         return false;