1
0

002-libbb-send_to_from-do-not-require-that-to-should-hav.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 7cef4817d6d6d61a1166ed7dfc13537b95c65970 Mon Sep 17 00:00:00 2001
  2. From: Denys Vlasenko <vda.linux@googlemail.com>
  3. Date: Thu, 15 Sep 2016 13:20:51 +0200
  4. Subject: [PATCH] libbb:/send_to_from: do not require that "to" should have the
  5. same AF. Closes 9146
  6. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  7. ---
  8. libbb/udp_io.c | 10 ++++++++--
  9. 1 file changed, 8 insertions(+), 2 deletions(-)
  10. --- a/libbb/udp_io.c
  11. +++ b/libbb/udp_io.c
  12. @@ -70,7 +70,13 @@ send_to_from(int fd, void *buf, size_t l
  13. msg.msg_flags = flags;
  14. cmsgptr = CMSG_FIRSTHDR(&msg);
  15. - if (to->sa_family == AF_INET && from->sa_family == AF_INET) {
  16. + /*
  17. + * Users report that to->sa_family can be AF_INET6 too,
  18. + * if "to" was acquired by recv_from_to(). IOW: recv_from_to()
  19. + * was seen showing IPv6 "from" even when the destination
  20. + * of received packet (our local address) was IPv4.
  21. + */
  22. + if (/* to->sa_family == AF_INET && */ from->sa_family == AF_INET) {
  23. struct in_pktinfo *pktptr;
  24. cmsgptr->cmsg_level = IPPROTO_IP;
  25. cmsgptr->cmsg_type = IP_PKTINFO;
  26. @@ -86,7 +92,7 @@ send_to_from(int fd, void *buf, size_t l
  27. pktptr->ipi_spec_dst = ((struct sockaddr_in*)from)->sin_addr;
  28. }
  29. # if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
  30. - else if (to->sa_family == AF_INET6 && from->sa_family == AF_INET6) {
  31. + else if (/* to->sa_family == AF_INET6 && */ from->sa_family == AF_INET6) {
  32. struct in6_pktinfo *pktptr;
  33. cmsgptr->cmsg_level = IPPROTO_IPV6;
  34. cmsgptr->cmsg_type = IPV6_PKTINFO;