VirtualBox

Ignore:
Timestamp:
Oct 27, 2018 2:27:30 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126196
Message:

VBoxNetLwf: More fixes for bugref:9233 ticketref:18046.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp

    r74484 r75121  
    13891389}
    13901390
     1391/**
     1392 * Worker for vboxNetLwfWinNBtoSG() that gets the max segment count needed.
     1393 * @note  vboxNetLwfWinNBtoSG may use fewer depending on cbPacket and offset!
     1394 */
    13911395DECLINLINE(ULONG) vboxNetLwfWinCalcSegments(PNET_BUFFER pNetBuf)
    13921396{
     
    15981602{
    15991603    ULONG cbPacket = NET_BUFFER_DATA_LENGTH(pNetBuf);
    1600     UINT cSegs = vboxNetLwfWinCalcSegments(pNetBuf);
     1604    ULONG cSegs = vboxNetLwfWinCalcSegments(pNetBuf);
    16011605    /* Allocate and initialize SG */
    16021606    PINTNETSG pSG = (PINTNETSG)NdisAllocateMemoryWithTagPriority(pModule->hFilter,
     
    16081612    IntNetSgInitTempSegs(pSG, cbPacket /*cbTotal*/, cSegs, cSegs /*cSegsUsed*/);
    16091613
    1610     int rc = NDIS_STATUS_SUCCESS;
    16111614    ULONG uOffset = NET_BUFFER_CURRENT_MDL_OFFSET(pNetBuf);
    16121615    cSegs = 0;
     
    16151618         pMdl = NDIS_MDL_LINKAGE(pMdl))
    16161619    {
    1617         PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority);
    1618         if (!pSrc)
    1619         {
    1620             rc = NDIS_STATUS_RESOURCES;
    1621             break;
    1622         }
    16231620        ULONG cbSrc = MmGetMdlByteCount(pMdl);
    16241621        if (cbSrc == 0)
    16251622            continue; /* Skip empty MDLs (see @bugref{9233}) */
    16261623
    1627         if (uOffset)
    1628         {
    1629             Assert(uOffset < cbSrc);
    1630             pSrc  += uOffset;
    1631             cbSrc -= uOffset;
    1632             uOffset = 0;
     1624        PUCHAR pSrc = (PUCHAR)MmGetSystemAddressForMdlSafe(pMdl, LowPagePriority);
     1625        if (!pSrc)
     1626        {
     1627            vboxNetLwfWinDestroySG(pSG);
     1628            return NULL;
    16331629        }
    16341630
     
    16361632            cbSrc = cbPacket;
    16371633
     1634        if (uOffset)
     1635        {
     1636            if (uOffset < cbSrc)
     1637            {
     1638                pSrc  += uOffset;
     1639                cbSrc -= uOffset;
     1640                uOffset = 0;
     1641            }
     1642            else
     1643            {
     1644                uOffset -= cbSrc;
     1645                continue;
     1646            }
     1647        }
     1648
     1649        Assert(cSegs < pSG->cSegsAlloc);
    16381650        pSG->aSegs[cSegs].pv = pSrc;
    16391651        pSG->aSegs[cSegs].cb = cbSrc;
     
    16431655    }
    16441656
    1645     Assert(cSegs <= pSG->cSegsAlloc);
    1646 
    1647     if (RT_FAILURE(rc))
    1648     {
    1649         vboxNetLwfWinDestroySG(pSG);
    1650         pSG = NULL;
    1651     }
    1652     else
    1653     {
    1654         Assert(cbPacket == 0);
    1655         Assert(pSG->cSegsUsed == cSegs);
    1656     }
     1657    Assert(cbPacket == 0);
     1658    Assert(cSegs <= pSG->cSegsUsed);
     1659
     1660    /* Update actual segment count in case we used fewer than anticipated. */
     1661    pSG->cSegsUsed = (uint16_t)cSegs;
     1662
    16571663    return pSG;
    16581664}
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