summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-07-02 22:26:04 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-07-02 22:26:07 +0900
commit899034ba8167bd16e802cfbea29a9ee85dee5be5 (patch)
tree5dc19a7c6379945227bbde7fb436e8a33cbe745d
parente95ec7cd1e363e1d55f59787c1e85f8f6c97e86c (diff)
downloadsystemd-899034ba8167bd16e802cfbea29a9ee85dee5be5.tar.gz
network: fix overflow issue in address lifetime calculation
Fixes another issue reported in #20050. See https://github.com/systemd/systemd/issues/20050#issuecomment-872967337.
-rw-r--r--src/network/networkd-ndisc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index eebcea1a69..efc4707855 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;
}