From: Arran Cudbard-Bell Date: Thu, 14 May 2020 22:59:19 +0000 (-0500) Subject: rlm_icmp: Ensure icmp header struct is correctly initialised X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db52de94e64ba467ce2e579b2e0656ea7aea50bc;p=thirdparty%2Ffreeradius-server.git rlm_icmp: Ensure icmp header struct is correctly initialised --- diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 505cdde48d8..a84fd31ccdf 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -106,7 +106,7 @@ static uint16_t icmp_checksum(uint8_t *data, size_t data_len, uint16_t checksum) p = data; end = data + data_len; while (p < end) { - sum += ((p[0] << 8) | p[1]); /* type / code */ + sum += fr_net_to_uint16(p); /* type / code */ p += 2; } @@ -238,13 +238,12 @@ static xlat_action_t xlat_icmp(TALLOC_CTX *ctx, UNUSED fr_cursor_t *out, RDEBUG("Sending ICMP request to %pV", echo->ip); - icmp.type = thread->t->request_type; - icmp.code = 0; - icmp.checksum = 0; - icmp.ident = thread->t->ident; - icmp.sequence = 0; - icmp.data = thread->t->data; - icmp.counter = echo->counter; + icmp = (icmp_header_t) { + .type = thread->t->request_type, + .ident = thread->t->ident, + .data = thread->t->data, + .counter = echo->counter + }; (void) fr_ipaddr_to_sockaddr(&echo->ip->vb_ip, 0, &dst, &salen);