VirtualBox

Changeset 79339 in vbox


Ignore:
Timestamp:
Jun 26, 2019 7:26:50 AM (6 years ago)
Author:
vboxsync
Message:

SharedOpenGL: fixed buffer size check in crFbImgFromDimOffVramBGRA, it incorrectly rejected empty rectangles, which of course fit into guest VRAM. bugref:9407

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp

    r78375 r79339  
    146146static int8_t crFbImgFromDimOffVramBGRA(VBOXCMDVBVAOFFSET offVRAM, uint32_t width, uint32_t height, CR_BLITTER_IMG *pImg)
    147147{
    148     uint32_t cbBuff;
    149 
    150     if (width == 0 || height == 0)
    151     {
    152         WARN(("invalid param"));
     148    if (offVRAM >= g_cbVRam)
     149    {
     150        WARN(("offVRAM invalid"));
    153151        return -1;
    154152    }
    155153
    156     cbBuff = width * height * 4;
    157     // Check if overflow happened
    158     if (cbBuff / width != height * 4)
    159     {
    160         WARN(("invalid param"));
    161         return -1;
    162     }
    163 
    164     if (offVRAM >= g_cbVRam
    165             || UINT32_MAX - cbBuff <= offVRAM
    166             || offVRAM + cbBuff >= g_cbVRam)
    167     {
    168         WARN(("invalid param"));
     154    uint32_t const cbAvailVRAM = g_cbVRam - offVRAM;
     155    uint32_t const cAvailScanlines = width ? cbAvailVRAM / (width * 4) : height;
     156    if (height > cAvailScanlines)
     157    {
     158        WARN(("Not enough space in VRAM"));
    169159        return -1;
    170160    }
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