From cc5184823fde84768d10ae42f20f843b65d52adc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 6 Feb 2022 23:25:07 +0900 Subject: [PATCH] sd-dhcp6-client: fix overflow in calculating timeout value --- src/libsystemd-network/sd-dhcp6-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index ff7e04bbdc6..a830b44f76d 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -808,6 +808,10 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) { return 0; } +static usec_t client_timeout_compute_random(usec_t val) { + return usec_sub_unsigned(val, random_u64_range(val / 10)); +} + static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata) { sd_dhcp6_client *client = userdata; @@ -861,10 +865,6 @@ static int client_timeout_resend_expire(sd_event_source *s, uint64_t usec, void return 0; } -static usec_t client_timeout_compute_random(usec_t val) { - return val - (random_u32() % USEC_PER_SEC) * val / 10 / USEC_PER_SEC; -} - static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userdata) { int r = 0; sd_dhcp6_client *client = userdata; -- 2.47.3