Skip to content

Commit

Permalink
network: fix overflow issue in address lifetime calculation
Browse files Browse the repository at this point in the history
Fixes another issue reported in systemd#20050. See
systemd#20050 (comment).
  • Loading branch information
yuwata committed Jul 2, 2021
1 parent e95ec7c commit 899034b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/network/networkd-ndisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 899034b

Please sign in to comment.