VirtualBox

Changeset 39523 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Dec 5, 2011 11:54:34 AM (13 years ago)
Author:
vboxsync
Message:

wddm: better parameter validation for DxgkDdiCreateAllocation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r39305 r39523  
    20942094        Assert(pCreateAllocation->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO));
    20952095        Assert(pCreateAllocation->pPrivateDriverData);
    2096         if (pCreateAllocation->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO))
    2097         {
    2098             PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
     2096        if (pCreateAllocation->PrivateDriverDataSize < sizeof (VBOXWDDM_RCINFO))
     2097        {
     2098            WARN(("invalid private data size (%d)", pCreateAllocation->PrivateDriverDataSize));
     2099            return STATUS_INVALID_PARAMETER;
     2100        }
     2101
     2102        PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
    20992103//            Assert(pRcInfo->RcDesc.VidPnSourceId < VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
    2100             Assert(pRcInfo->cAllocInfos == pCreateAllocation->NumAllocations);
    2101             pResource = (PVBOXWDDM_RESOURCE)vboxWddmMemAllocZero(RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pRcInfo->cAllocInfos]));
    2102             Assert(pResource);
    2103             if (pResource)
    2104             {
    2105                 pResource->cRefs = 1;
    2106                 pResource->cAllocations = pRcInfo->cAllocInfos;
    2107                 pResource->fFlags = pRcInfo->fFlags;
    2108                 pResource->RcDesc = pRcInfo->RcDesc;
    2109             }
    2110             else
    2111                 Status = STATUS_NO_MEMORY;
    2112         }
    2113         else
    2114             Status = STATUS_INVALID_PARAMETER;
    2115     }
    2116 
    2117     if (Status == STATUS_SUCCESS)
    2118     {
    2119         for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
    2120         {
    2121             Status = vboxWddmAllocationCreate(pDevExt, pResource, i, &pCreateAllocation->pAllocationInfo[i]);
    2122             Assert(Status == STATUS_SUCCESS);
    2123             if (Status != STATUS_SUCCESS)
    2124             {
    2125                 LOGREL(("ERROR: vboxWddmAllocationCreate error (0x%x)", Status));
    2126                 /* note: i-th allocation is expected to be cleared in a fail handling code above */
    2127                 for (UINT j = 0; j < i; ++j)
    2128                 {
    2129                     vboxWddmAllocationCleanup(pDevExt, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
    2130                     vboxWddmAllocationRelease((PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
    2131                 }
    2132             }
    2133         }
    2134 
    2135         pCreateAllocation->hResource = pResource;
    2136         if (pResource && Status != STATUS_SUCCESS)
    2137             vboxWddmResourceRelease(pResource);
    2138     }
     2104        if (pRcInfo->cAllocInfos != pCreateAllocation->NumAllocations)
     2105        {
     2106            WARN(("invalid number of allocations passed in, (%d), expected (%d)", pRcInfo->cAllocInfos, pCreateAllocation->NumAllocations));
     2107            return STATUS_INVALID_PARAMETER;
     2108        }
     2109
     2110        pResource = (PVBOXWDDM_RESOURCE)vboxWddmMemAllocZero(RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pRcInfo->cAllocInfos]));
     2111        if (!pResource)
     2112        {
     2113            WARN(("vboxWddmMemAllocZero failed for (%d) allocations", pRcInfo->cAllocInfos));
     2114            return STATUS_NO_MEMORY;
     2115        }
     2116
     2117        pResource->cRefs = 1;
     2118        pResource->cAllocations = pRcInfo->cAllocInfos;
     2119        pResource->fFlags = pRcInfo->fFlags;
     2120        pResource->RcDesc = pRcInfo->RcDesc;
     2121    }
     2122
     2123
     2124    for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
     2125    {
     2126        Status = vboxWddmAllocationCreate(pDevExt, pResource, i, &pCreateAllocation->pAllocationInfo[i]);
     2127        if (Status != STATUS_SUCCESS)
     2128        {
     2129            WARN(("vboxWddmAllocationCreate(%d) failed, Status(0x%x)", i, Status));
     2130            /* note: i-th allocation is expected to be cleared in a fail handling code above */
     2131            for (UINT j = 0; j < i; ++j)
     2132            {
     2133                vboxWddmAllocationCleanup(pDevExt, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
     2134                vboxWddmAllocationRelease((PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
     2135            }
     2136        }
     2137    }
     2138
     2139    pCreateAllocation->hResource = pResource;
     2140    if (pResource && Status != STATUS_SUCCESS)
     2141        vboxWddmResourceRelease(pResource);
     2142
    21392143    LOGF(("LEAVE, status(0x%x), context(0x%x)", Status, hAdapter));
    21402144
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