udp6: set the destination port unconditionally.

Even if the caller provides the destination address, still the port must
depend on the passed 'event' value for correct delivery.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-29 10:31:39 +02:00
parent 8d1b30d91c
commit 1e35b91c6a
1 changed files with 2 additions and 3 deletions

5
udp6.c
View File

@ -223,9 +223,6 @@ static int udp6_send(struct transport *t, struct fdarray *fda, int event,
addr_buf.sin6.sin6_family = AF_INET6; addr_buf.sin6.sin6_family = AF_INET6;
addr_buf.sin6.sin6_addr = peer ? mc6_addr[MC_PDELAY] : addr_buf.sin6.sin6_addr = peer ? mc6_addr[MC_PDELAY] :
mc6_addr[MC_PRIMARY]; mc6_addr[MC_PRIMARY];
addr_buf.sin6.sin6_port = htons(event ? EVENT_PORT :
GENERAL_PORT);
if (is_link_local(&addr_buf.sin6.sin6_addr)) if (is_link_local(&addr_buf.sin6.sin6_addr))
addr_buf.sin6.sin6_scope_id = udp6->index; addr_buf.sin6.sin6_scope_id = udp6->index;
@ -233,6 +230,8 @@ static int udp6_send(struct transport *t, struct fdarray *fda, int event,
addr = &addr_buf; addr = &addr_buf;
} }
addr->sin6.sin6_port = htons(event ? EVENT_PORT : GENERAL_PORT);
len += 2; /* Extend the payload by two, for UDP checksum corrections. */ len += 2; /* Extend the payload by two, for UDP checksum corrections. */
cnt = sendto(fd, buf, len, 0, &addr->sa, sizeof(addr->sin6)); cnt = sendto(fd, buf, len, 0, &addr->sa, sizeof(addr->sin6));