VirtualBox

Changeset 11124 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 4, 2008 9:07:40 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34061
Message:

intnet: Fixed bug in intnetR0SgReadByte found testing badly segement buffers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r11123 r11124  
    402402        return ((uint8_t const *)pSG->aSegs[0].pv)[off];
    403403
     404    off -= pSG->aSegs[0].cb;
    404405    unsigned const cSegs = pSG->cSegsUsed; Assert(cSegs == pSG->cSegsUsed);
    405406    for (unsigned iSeg = 1; iSeg < cSegs; iSeg++)
    406407    {
    407         if (pSG->aSegs[iSeg].cb > 0)
     408        if (pSG->aSegs[iSeg].cb > off)
    408409            return ((uint8_t const *)pSG->aSegs[iSeg].pv)[off];
    409410        off -= pSG->aSegs[iSeg].cb;
     
    22442245     */
    22452246    RTNETETHERHDR EthHdr;
    2246     if (RT_LIKELY(pSG->aSegs[0].cb >= sizeof(EthHdr)))
     2247    if (pSG->aSegs[0].cb >= sizeof(EthHdr))
    22472248        EthHdr = *(PCRTNETETHERHDR)pSG->aSegs[0].pv;
    2248     else
    2249     {
    2250         uint8_t *pbDst = (uint8_t *)&EthHdr;
    2251         size_t   cbLeft = sizeof(EthHdr);
    2252         for (unsigned iSeg = 0; cbLeft && iSeg < pSG->cSegsUsed; iSeg++)
    2253         {
    2254             size_t cb = RT_MIN(cbLeft, pSG->aSegs[iSeg].cb);
    2255             memcpy(pbDst, pSG->aSegs[iSeg].pv, cb);
    2256             pbDst += cb;
    2257             cbLeft -= cb;
    2258         }
    2259         AssertReturn(!cbLeft, false);
    2260     }
     2249    else if (!intnetR0SgReadPart(pSG, 0, sizeof(EthHdr), &EthHdr))
     2250        return false;
    22612251    if (    (EthHdr.DstMac.au8[0] == 0x08 && EthHdr.DstMac.au8[1] == 0x00 && EthHdr.DstMac.au8[2] == 0x27)
    22622252        ||  (EthHdr.SrcMac.au8[0] == 0x08 && EthHdr.SrcMac.au8[1] == 0x00 && EthHdr.SrcMac.au8[2] == 0x27)
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