summaryrefslogtreecommitdiff
path: root/libbb/udp_io.c
diff options
context:
space:
mode:
authorDenys Vlasenko2016-09-15 13:20:51 +0200
committerDenys Vlasenko2016-09-15 13:20:51 +0200
commit7cef4817d6d6d61a1166ed7dfc13537b95c65970 (patch)
tree8dedd8f5e9584129cf54179ddd29ef2042a3923e /libbb/udp_io.c
parent3a45b87ac36f60962d6d19c592813e186a9e82e6 (diff)
downloadbusybox-7cef4817d6d6d61a1166ed7dfc13537b95c65970.zip
busybox-7cef4817d6d6d61a1166ed7dfc13537b95c65970.tar.gz
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>
Diffstat (limited to 'libbb/udp_io.c')
-rw-r--r--libbb/udp_io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libbb/udp_io.c b/libbb/udp_io.c
index a32af9b..6e3ef48 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,
msg.msg_flags = flags;
cmsgptr = CMSG_FIRSTHDR(&msg);
- if (to->sa_family == AF_INET && from->sa_family == AF_INET) {
+ /*
+ * Users report that to->sa_family can be AF_INET6 too,
+ * if "to" was acquired by recv_from_to(). IOW: recv_from_to()
+ * was seen showing IPv6 "from" even when the destination
+ * of received packet (our local address) was IPv4.
+ */
+ if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) {
struct in_pktinfo *pktptr;
cmsgptr->cmsg_level = IPPROTO_IP;
cmsgptr->cmsg_type = IP_PKTINFO;
@@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t len, int flags,
pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr;
}
# if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
- else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) {
+ else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) {
struct in6_pktinfo *pktptr;
cmsgptr->cmsg_level = IPPROTO_IPV6;
cmsgptr->cmsg_type = IPV6_PKTINFO;