VirtualBox

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


Ignore:
Timestamp:
Dec 14, 2010 11:05:57 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68893
Message:

VSCSI: Fix read beyond end of S/G array

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSISgBuf.cpp

    r28800 r35062  
    4949    uint8_t *pbBuf = pIoMemCtx->pbBuf;
    5050
    51     pIoMemCtx->cbBufLeft -= cbData;
     51    if (   pbBuf
     52        && cbData)
     53    {
     54        pIoMemCtx->cbBufLeft -= cbData;
    5255
    53     /* Advance to the next segment if required. */
    54     if (!pIoMemCtx->cbBufLeft)
    55     {
    56         pIoMemCtx->iSegIdx++;
     56        /* Advance to the next segment if required. */
     57        if (!pIoMemCtx->cbBufLeft)
     58        {
     59            pIoMemCtx->iSegIdx++;
    5760
    58         if (RT_UNLIKELY(pIoMemCtx->iSegIdx == pIoMemCtx->cSegments))
    59         {
    60             pIoMemCtx->cbBufLeft = 0;
    61             pIoMemCtx->pbBuf     = NULL;
     61            if (RT_UNLIKELY(pIoMemCtx->iSegIdx == pIoMemCtx->cSegments))
     62            {
     63                pIoMemCtx->cbBufLeft = 0;
     64                pIoMemCtx->pbBuf     = NULL;
     65            }
     66            else
     67            {
     68                pIoMemCtx->pbBuf     = (uint8_t *)pIoMemCtx->paDataSeg[pIoMemCtx->iSegIdx].pvSeg;
     69                pIoMemCtx->cbBufLeft = pIoMemCtx->paDataSeg[pIoMemCtx->iSegIdx].cbSeg;
     70            }
    6271        }
    6372        else
    64         {
    65             pIoMemCtx->pbBuf     = (uint8_t *)pIoMemCtx->paDataSeg[pIoMemCtx->iSegIdx].pvSeg;
    66             pIoMemCtx->cbBufLeft = pIoMemCtx->paDataSeg[pIoMemCtx->iSegIdx].cbSeg;
    67         }
     73            pIoMemCtx->pbBuf += cbData;
     74    }
    6875
    69         *pcbData = cbData;
    70     }
    71     else
    72         pIoMemCtx->pbBuf += cbData;
     76    *pcbData = cbData;
    7377
    7478    return pbBuf;
Note: See TracChangeset for help on using the changeset viewer.

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