Ticket #327: patch-dn-socket.diff

File patch-dn-socket.diff, 1.1 KB (added by Dan Nelson, 11 years ago)

use the correct length values for BSD's sendmsg()

  • src/openvpn/socket.c

    *** diff
    
    set message length to the correct value for the IP_RECVDSTADDR case
    
     
    27992799        mesg.msg_name = &to->dest.addr.sa;
    28002800        mesg.msg_namelen = sizeof (struct sockaddr_in);
    28012801        mesg.msg_control = &opi;
    2802         mesg.msg_controllen = sizeof (struct openvpn_in4_pktinfo);
    28032802        mesg.msg_flags = 0;
    28042803        cmsg = CMSG_FIRSTHDR (&mesg);
    2805         cmsg->cmsg_len = sizeof (struct openvpn_in4_pktinfo);
    28062804#ifdef HAVE_IN_PKTINFO
     2805        mesg.msg_controllen = sizeof (struct openvpn_in4_pktinfo);
     2806        cmsg->cmsg_len = sizeof (struct openvpn_in4_pktinfo);
    28072807        cmsg->cmsg_level = SOL_IP;
    28082808        cmsg->cmsg_type = IP_PKTINFO;
    28092809        {
     
    28142814        pkti->ipi_addr.s_addr = 0;
    28152815        }
    28162816#elif defined(IP_RECVDSTADDR)
     2817        mesg.msg_controllen = CMSG_SPACE(sizeof (struct in_addr));
     2818        cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
    28172819        cmsg->cmsg_level = IPPROTO_IP;
    28182820        cmsg->cmsg_type = IP_RECVDSTADDR;
    28192821        *(struct in_addr *) CMSG_DATA (cmsg) = to->pi.in4;