]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix overflow issue in address lifetime calculation 20108/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Jul 2021 13:26:04 +0000 (22:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Jul 2021 13:26:07 +0000 (22:26 +0900)
Fixes another issue reported in #20050. See
https://github.com/systemd/systemd/issues/20050#issuecomment-872967337.

src/network/networkd-ndisc.c

index eebcea1a690cf13f057361cc03d4a9b1c3717586..efc47078550847c7695012c261d30fd6b44a6521 100644 (file)
@@ -819,8 +819,10 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
                 r = address_get(link, address, &e);
                 if (r > 0) {
                         /* If the address is already assigned, but not valid anymore, then refuse to
-                         * update the address. */
-                        if (e->cinfo.tstamp / 100 + e->cinfo.ifa_valid < time_now / USEC_PER_SEC)
+                         * update the address, and it will be removed. */
+                        if (e->cinfo.ifa_valid != CACHE_INFO_INFINITY_LIFE_TIME &&
+                            usec_add(e->cinfo.tstamp / 100 * USEC_PER_SEC,
+                                     e->cinfo.ifa_valid * USEC_PER_SEC) < time_now)
                                 continue;
                 }