summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-02-06 15:25:07 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-02-14 06:43:45 +0100
commitcc5184823fde84768d10ae42f20f843b65d52adc (patch)
tree98ef0543fec373e0156c6de66e084ec55371ab55 /src
parentsd-dhcp6-client: disable event source when client is stopped or freed (diff)
downloadsystemd-cc5184823fde84768d10ae42f20f843b65d52adc.tar.xz
systemd-cc5184823fde84768d10ae42f20f843b65d52adc.zip
sd-dhcp6-client: fix overflow in calculating timeout value
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index ff7e04bbdc..a830b44f76 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;