VirtualBox

Ticket #2932: tcp_subr.diff

File tcp_subr.diff, 1.6 KB (added by Lawrence Rust, 16 years ago)
  • tcp_subr.c

    old new  
    667667                /*
    668668                 * Need to emulate the PORT command
    669669                 */
     670                struct sockaddr_in addr;
     671                socklen_t addrlen = sizeof addr;
     672
     673                if ( getsockname(so->s,(struct sockaddr *)&addr,&addrlen))
     674                    return 1;
     675
    670676                x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]",
    671677                           &n1, &n2, &n3, &n4, &n5, &n6, buff);
    672678                if (x < 6)
     
    683689                n5 = (n6 >> 8) & 0xff;
    684690                n6 &= 0xff;
    685691
    686                 laddr = ntohl(so->so_faddr.s_addr);
     692                laddr = ntohl(addr.sin_addr.s_addr);
    687693
    688694                n1 = ((laddr >> 24) & 0xff);
    689695                n2 = ((laddr >> 16) & 0xff);
     
    700706                /*
    701707                 * Need to emulate the PASV response
    702708                 */
     709                struct sockaddr_in addr;
     710                socklen_t addrlen = sizeof addr;
     711
     712                if ( getsockname(so->s,(struct sockaddr *)&addr,&addrlen))
     713                    return 1;
     714
    703715                x = sscanf(bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]",
    704716                           &n1, &n2, &n3, &n4, &n5, &n6, buff);
    705717                if (x < 6)
     
    716728                n5 = (n6 >> 8) & 0xff;
    717729                n6 &= 0xff;
    718730
    719                 laddr = ntohl(so->so_faddr.s_addr);
     731                laddr = ntohl(addr.sin_addr.s_addr);
    720732
    721733                n1 = ((laddr >> 24) & 0xff);
    722734                n2 = ((laddr >> 16) & 0xff);

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy