]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6: fix coverity overflow issues
authorPat Ruddy <pat@voltanet.io>
Fri, 25 Jun 2021 08:39:21 +0000 (09:39 +0100)
committerPat Ruddy <pat@voltanet.io>
Sat, 26 Jun 2021 10:16:19 +0000 (11:16 +0100)
Coverity flagged the possibility of an overflow in the latency
calculation, ensure that 64 bit integers are used in the
calculation to avoid this error.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
ospf6d/ospf6_message.c

index 5f23aab80af7ecbdec80664dc1d9db0f584be2eb..8d74585ec62fe8af6636aa12991e9705c2d222e6 100644 (file)
@@ -444,9 +444,9 @@ static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst,
        /* check latency against hello period */
        if (on->hello_in)
                latency = monotime_since(&on->last_hello, NULL)
-                         - (oi->hello_interval * 1000000);
+                         - ((int64_t)oi->hello_interval * 1000000);
        /* log if latency exceeds the hello period */
-       if (latency > (oi->hello_interval * 1000000))
+       if (latency > ((int64_t)oi->hello_interval * 1000000))
                zlog_warn("%s RX %pI4 high latency %" PRId64 "us.", __func__,
                          &on->router_id, latency);
        on->last_hello = timestamp;
@@ -1943,10 +1943,11 @@ static int ospf6_write(struct thread *thread)
                        monotime(&timestamp);
                        if (oi->hello_out)
                                latency = monotime_since(&oi->last_hello, NULL)
-                                         - (oi->hello_interval * 1000000);
+                                         - ((int64_t)oi->hello_interval
+                                            * 1000000);
 
                        /* log if latency exceeds the hello period */
-                       if (latency > (oi->hello_interval * 1000000))
+                       if (latency > ((int64_t)oi->hello_interval * 1000000))
                                zlog_warn("%s hello TX high latency %" PRId64
                                          "us.",
                                          __func__, latency);