VirtualBox

Changeset 51864 in vbox for trunk/src


Ignore:
Timestamp:
Jul 4, 2014 4:12:56 AM (11 years ago)
Author:
vboxsync
Message:

NAT: sbappend - check if we are going to send before allocating buffer
to send. While here, fix typo in comment.

File:
1 edited

Legend:

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

    r44528 r51864  
    112112    int ret = 0;
    113113    int mlen = 0;
    114     caddr_t buf = NULL;
    115114
    116115    STAM_PROFILE_START(&pData->StatIOSBAppend_pf, a);
     
    141140    /*
    142141     * We only write if there's nothing in the buffer,
    143      * ottherwise it'll arrive out of order, and hence corrupt
    144      */
    145     if (m->m_next)
    146     {
    147         buf = RTMemAlloc(mlen);
    148         if (buf == NULL)
     142     * otherwise it'll arrive out of order, and hence corrupt
     143     */
     144    if (so->so_rcv.sb_cc == 0)
     145    {
     146        caddr_t buf = NULL;
     147
     148        if (m->m_next)
    149149        {
    150             ret = 0;
    151             goto no_sent;
     150            buf = RTMemAlloc(mlen);
     151            if (buf == NULL)
     152            {
     153                ret = 0;
     154                goto no_sent;
     155            }
     156            m_copydata(m, 0, mlen, buf);
    152157        }
    153         m_copydata(m, 0, mlen, buf);
    154     }
    155     else
    156         buf = mtod(m, char *);
    157 
    158     if(!so->so_rcv.sb_cc)
     158        else
     159            buf = mtod(m, char *);
     160
    159161        ret = send(so->s, buf, mlen, 0);
    160162
    161     if (m->m_next)
    162         RTMemFree(buf);
     163        if (m->m_next)
     164            RTMemFree(buf);
     165    }
    163166no_sent:
    164167
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