ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/s_bsd.c
(Generate patch)

Comparing ircd-hybrid-7.3/src/s_bsd.c (file contents):
Revision 1072 by michael, Wed Feb 17 22:58:23 2010 UTC vs.
Revision 1122 by michael, Mon Jan 10 09:14:19 2011 UTC

# Line 747 | Line 747 | comm_accept(struct Listener *lptr, struc
747  
748   /*
749   * remove_ipv6_mapping() - Removes IPv4-In-IPv6 mapping from an address
750 < * This function should really inspect the struct itself rather than relying
751 < * on inet_pton and inet_ntop.  OSes with IPv6 mapping listening on both
750 > * OSes with IPv6 mapping listening on both
751   * AF_INET and AF_INET6 map AF_INET connections inside AF_INET6 structures
752   *
753   */
# Line 758 | Line 757 | remove_ipv6_mapping(struct irc_ssaddr *a
757   {
758    if (addr->ss.ss_family == AF_INET6)
759    {
760 <    struct sockaddr_in6 *v6;
762 <
763 <    v6 = (struct sockaddr_in6*)addr;
764 <    if (IN6_IS_ADDR_V4MAPPED(&v6->sin6_addr))
760 >    if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)addr)->sin6_addr))
761      {
762 <      char v4ip[HOSTIPLEN];
763 <      struct sockaddr_in *v4 = (struct sockaddr_in*)addr;
764 <      inetntop(AF_INET6, &v6->sin6_addr, v4ip, HOSTIPLEN);
765 <      inet_pton(AF_INET, v4ip, &v4->sin_addr);
762 >      struct sockaddr_in6 v6;
763 >      struct sockaddr_in *v4 = (struct sockaddr_in *)addr;
764 >
765 >      memcpy(&v6, addr, sizeof(v6));
766 >      memset(v4, 0, sizeof(struct sockaddr_in));
767 >      memcpy(&v4->sin_addr, &v6.sin6_addr.s6_addr[12], sizeof(v4->sin_addr));
768 >
769        addr->ss.ss_family = AF_INET;
770        addr->ss_len = sizeof(struct sockaddr_in);
771      }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)