From: Yu Watanabe Date: Fri, 2 Jul 2021 13:26:04 +0000 (+0900) Subject: network: fix overflow issue in address lifetime calculation X-Git-Tag: v249~20^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=899034ba8167bd16e802cfbea29a9ee85dee5be5;p=thirdparty%2Fsystemd.git network: fix overflow issue in address lifetime calculation Fixes another issue reported in #20050. See https://github.com/systemd/systemd/issues/20050#issuecomment-872967337. --- diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index eebcea1a690..efc47078550 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -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; }