]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: route: fix possible overflow in conversion usec_t -> uint32_t
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 Oct 2021 01:06:25 +0000 (10:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 18 Oct 2021 15:58:33 +0000 (00:58 +0900)
src/network/networkd-route.c

index f7ef657bcaa40db9782375b63820a8cbbd5efc36..767f47a8b4c2e7905bd1e3d766febf339a2a1fc0 100644 (file)
@@ -1391,7 +1391,7 @@ static int route_configure(
 
         if (route->lifetime != USEC_INFINITY && kernel_route_expiration_supported()) {
                 r = sd_netlink_message_append_u32(req, RTA_EXPIRES,
-                        DIV_ROUND_UP(usec_sub_unsigned(route->lifetime, now(clock_boottime_or_monotonic())), USEC_PER_SEC));
+                        MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime, now(clock_boottime_or_monotonic())), USEC_PER_SEC), UINT32_MAX));
                 if (r < 0)
                         return log_link_error_errno(link, r, "Could not append RTA_EXPIRES attribute: %m");
         }