VirtualBox

Changeset 83617 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 8, 2020 9:21:02 AM (5 years ago)
Author:
vboxsync
Message:

VUSB: Avoid too large URBs (see bugref:9697).

Location:
trunk/src/VBox/Devices/USB
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r82968 r83617  
    380380    RT_NOREF(pszTag);
    381381    PVUSBURBPOOL pUrbPool = &pRh->Hub.Dev.UrbPool;
     382
     383    if (RT_UNLIKELY(cbData > (32 * _1M)))
     384    {
     385        LogFunc(("Bad URB size (%u)!\n", cbData));
     386        return NULL;
     387    }
    382388
    383389    if (!pDev)
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r83592 r83617  
    703703    if (pExtra->cbMax < cbBuf + pSetupIn->wLength + sizeof(VUSBURBVUSBINT))
    704704    {
     705#if 1
     706        LogRelMax(10, ("VUSB: Control URB too large (wLength=%u)!\n", pSetupIn->wLength));
     707        return false;
     708#else
    705709        uint32_t cbReq = RT_ALIGN_32(cbBuf + pSetupIn->wLength + sizeof(VUSBURBVUSBINT), 1024);
    706710        PVUSBCTRLEXTRA pNew = (PVUSBCTRLEXTRA)RTMemRealloc(pExtra, RT_UOFFSETOF_DYN(VUSBCTRLEXTRA, Urb.abData[cbReq]));
     
    717721            pPipe->pCtrl = pExtra;
    718722        }
     723
     724        PVUSBURBVUSB pOldVUsb = (PVUSBURBVUSB)&pExtra->Urb.abData[pExtra->cbMax - sizeof(VUSBURBVUSBINT)];
    719725        pExtra->Urb.pVUsb = (PVUSBURBVUSB)&pExtra->Urb.abData[cbBuf + pSetupIn->wLength];
     726        memmove(pExtra->Urb.pVUsb, pOldVUsb, sizeof(VUSBURBVUSBINT));
     727        memset(pOldVUsb, 0, (uint8_t *)pExtra->Urb.pVUsb - (uint8_t *)pOldVUsb);
    720728        pExtra->Urb.pVUsb->pUrb = &pExtra->Urb;
     729        pExtra->Urb.pVUsb->pvFreeCtx = &pExtra->Urb;
    721730        pExtra->cbMax = cbReq;
     731
     732#endif
    722733    }
    723734    Assert(pExtra->Urb.enmState == VUSBURBSTATE_ALLOCATED);
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