diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-09-15 13:20:51 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-09-15 13:20:51 +0200 |
commit | 7cef4817d6d6d61a1166ed7dfc13537b95c65970 (patch) | |
tree | 8dedd8f5e9584129cf54179ddd29ef2042a3923e | |
parent | 3a45b87ac36f60962d6d19c592813e186a9e82e6 (diff) | |
download | busybox-w32-7cef4817d6d6d61a1166ed7dfc13537b95c65970.tar.gz busybox-w32-7cef4817d6d6d61a1166ed7dfc13537b95c65970.tar.bz2 busybox-w32-7cef4817d6d6d61a1166ed7dfc13537b95c65970.zip |
libbb:/send_to_from: do not require that "to" should have the same AF. Closes 9146
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/udp_io.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libbb/udp_io.c b/libbb/udp_io.c index a32af9bd2..6e3ef484e 100644 --- a/libbb/udp_io.c +++ b/libbb/udp_io.c | |||
@@ -70,7 +70,13 @@ send_to_from(int fd, void *buf, size_t len, int flags, | |||
70 | msg.msg_flags = flags; | 70 | msg.msg_flags = flags; |
71 | 71 | ||
72 | cmsgptr = CMSG_FIRSTHDR(&msg); | 72 | cmsgptr = CMSG_FIRSTHDR(&msg); |
73 | if (to->sa_family == AF_INET && from->sa_family == AF_INET) { | 73 | /* |
74 | * Users report that to->sa_family can be AF_INET6 too, | ||
75 | * if "to" was acquired by recv_from_to(). IOW: recv_from_to() | ||
76 | * was seen showing IPv6 "from" even when the destination | ||
77 | * of received packet (our local address) was IPv4. | ||
78 | */ | ||
79 | if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) { | ||
74 | struct in_pktinfo *pktptr; | 80 | struct in_pktinfo *pktptr; |
75 | cmsgptr->cmsg_level = IPPROTO_IP; | 81 | cmsgptr->cmsg_level = IPPROTO_IP; |
76 | cmsgptr->cmsg_type = IP_PKTINFO; | 82 | cmsgptr->cmsg_type = IP_PKTINFO; |
@@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t len, int flags, | |||
86 | pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr; | 92 | pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr; |
87 | } | 93 | } |
88 | # if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) | 94 | # if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) |
89 | else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) { | 95 | else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) { |
90 | struct in6_pktinfo *pktptr; | 96 | struct in6_pktinfo *pktptr; |
91 | cmsgptr->cmsg_level = IPPROTO_IPV6; | 97 | cmsgptr->cmsg_level = IPPROTO_IPV6; |
92 | cmsgptr->cmsg_type = IPV6_PKTINFO; | 98 | cmsgptr->cmsg_type = IPV6_PKTINFO; |