VirtualBox

Ignore:
Timestamp:
Jul 3, 2013 9:59:12 AM (11 years ago)
Author:
vboxsync
Message:

Missing break in complicated vboxNetFltLinuxFrameSize case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r46904 r46922  
    565565DECLINLINE(uint32_t) vboxNetFltLinuxFrameSize(PINTNETSG pSG)
    566566{
    567     RTNETETHERHDR EthHdr;
    568     uint16_t      u16Type = 0;
    569     uint32_t      cbVlanTag = 0;
    570     if (pSG->aSegs[0].cb >= sizeof(EthHdr))
     567    uint16_t u16Type = 0;
     568    uint32_t cbVlanTag = 0;
     569    if (pSG->aSegs[0].cb >= sizeof(RTNETETHERHDR))
    571570        u16Type = RT_BE2H_U16(((PCRTNETETHERHDR)pSG->aSegs[0].pv)->EtherType);
    572     else if (pSG->cbTotal >= sizeof(EthHdr))
    573     {
    574         uint32_t i, uOffset = RT_OFFSETOF(RTNETETHERHDR, EtherType);
     571    else if (pSG->cbTotal >= sizeof(RTNETETHERHDR))
     572    {
     573        uint32_t off = RT_OFFSETOF(RTNETETHERHDR, EtherType);
     574        uint32_t i;
    575575        for (i = 0; i < pSG->cSegsUsed; ++i)
    576576        {
    577             if (uOffset > pSG->aSegs[i].cb)
     577            if (off <= pSG->aSegs[i].cb)
    578578            {
    579                 uOffset -= pSG->aSegs[i].cb;
    580                 continue;
     579                if (off + sizeof(uint16_t) <= pSG->aSegs[i].cb)
     580                    u16Type = RT_BE2H_U16(*(uint16_t *)((uintptr_t)pSG->aSegs[i].pv + off));
     581                else if (i + 1 < pSG->cSegsUsed)
     582                    u16Type = RT_BE2H_U16(  ((uint16_t)( ((uint8_t *)pSG->aSegs[i].pv)[off] ) << 8)
     583                                          + *(uint8_t *)pSG->aSegs[i + 1].pv); /* ASSUMES no empty segments! */
     584                /* else: frame is too short. */
     585                break;
    581586            }
    582             if (uOffset + sizeof(uint16_t) > pSG->aSegs[i].cb)
    583             {
    584                 if (i + 1 < pSG->cSegsUsed)
    585                     u16Type = RT_BE2H_U16(  ((uint16_t)( ((uint8_t*)pSG->aSegs[i].pv)[uOffset] ) << 8)
    586                                           + *(uint8_t*)pSG->aSegs[i + 1].pv);
    587             }
    588             else
    589                 u16Type = RT_BE2H_U16(*(uint16_t*)((uint8_t*)pSG->aSegs[i].pv + uOffset));
     587            off -= pSG->aSegs[i].cb;
    590588        }
    591589    }
     
    619617    if (fDstWire && (vboxNetFltLinuxFrameSize(pSG) > ASMAtomicReadU32(&pThis->u.s.cbMtu) + 14))
    620618    {
    621         static bool fOnce = true;
    622         if (fOnce)
    623         {
    624             fOnce = false;
     619        static bool s_fOnce = true;
     620        if (s_fOnce)
     621        {
     622            s_fOnce = false;
    625623            printk("VBoxNetFlt: Dropped over-sized packet (%d bytes) coming from internal network.\n", vboxNetFltLinuxFrameSize(pSG));
    626624        }
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