VirtualBox

Changeset 23004 in vbox


Ignore:
Timestamp:
Sep 14, 2009 2:03:27 PM (15 years ago)
Author:
vboxsync
Message:

NAT: 1. don't load ioctlsocket with unintiolized values (SL fills it with garbage).

  1. don't limit icmp with 1500 bytes, check bytes ready for read before.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r22946 r23004  
    564564        struct ethhdr *eh;
    565565        ssize_t len;
    566         u_long n;
     566        u_long n = 0;
    567567#ifdef VBOX_WITH_SLIRP_BSD_MBUF
    568568        uint8_t *buffer;
     
    589589        /* if (so->so_fport != htons(53)) */
    590590        {
    591             ioctlsocket(so->s, FIONREAD, &n);
    592 
    593             if (n > len)
     591            static int signaled = 0;
     592            int rc = ioctlsocket(so->s, FIONREAD, &n);
     593           
     594            if (rc == -1 && signaled == 0)
     595            {
     596                LogRel(("NAT: can't fetch amount of bytes on socket %R[natsock], so message will be truncated.\n", so));
     597                signaled = 1;
     598            }
     599
     600            if (rc > 0 && n > len)
    594601            {
    595602                n = (m->m_data - m->m_dat) + m->m_len + n + 1;
     
    12101217    struct sockaddr_in addr;
    12111218    socklen_t addrlen = sizeof(struct sockaddr_in);
    1212     char buff[1500];
    1213     int len;
    1214     len = recvfrom(so->s, buff, 1500, 0,
     1219    char *buff;
     1220    int len = 0;
     1221    int rc = 0;
     1222    static int signalled = 0;
     1223    rc = ioctlsocket(so->s, FIONREAD, &len);
     1224    if (rc != -1 && signalled == 0)
     1225    {
     1226        signalled = 1;
     1227        LogRel(("NAT: fetching number of bits has been failed for ICMP socket \n"));
     1228    }
     1229    len = (len != 0 && rc != -1 ? len : 1500);
     1230    buff = RTMemAlloc(len);
     1231    len = recvfrom(so->s, buff, len, 0,
    12151232                   (struct sockaddr *)&addr, &addrlen);
    12161233    /* XXX Check if reply is "correct"? */
     
    12341251        send_icmp_to_guest(pData, buff, len, so, &addr);
    12351252    }
     1253    RTMemFree(buff);
    12361254}
    12371255#endif /* !RT_OS_WINDOWS */
Note: See TracChangeset for help on using the changeset viewer.

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