Andrew Nguyen : ddraw: Validate structure pointers and sizes in IDirect3D3: :FindDevice.
Alexandre Julliard
julliard at winehq.org
Tue Jun 22 10:49:32 CDT 2010
Module: wine
Branch: master
Commit: 10a076ad8d653db5d626310464033c9c1a6929e8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=10a076ad8d653db5d626310464033c9c1a6929e8
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Mon Jun 21 10:14:51 2010 -0500
ddraw: Validate structure pointers and sizes in IDirect3D3::FindDevice.
---
dlls/ddraw/direct3d.c | 7 +++++++
dlls/ddraw/tests/d3d.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/dlls/ddraw/direct3d.c b/dlls/ddraw/direct3d.c
index 3f2410f..f919860 100644
--- a/dlls/ddraw/direct3d.c
+++ b/dlls/ddraw/direct3d.c
@@ -666,6 +666,13 @@ IDirect3DImpl_3_FindDevice(IDirect3D3 *iface,
TRACE("(%p)->(%p,%p)\n", This, D3DDFS, D3DFDR);
+ if (!D3DDFS || !D3DFDR)
+ return DDERR_INVALIDPARAMS;
+
+ if (D3DDFS->dwSize != sizeof(D3DFINDDEVICESEARCH) ||
+ D3DFDR->dwSize != sizeof(D3DFINDDEVICERESULT))
+ return DDERR_INVALIDPARAMS;
+
if ((D3DDFS->dwFlags & D3DFDS_COLORMODEL) &&
(D3DDFS->dcmColorModel != D3DCOLOR_RGB))
{
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index 26dc1cf..e74fb79 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -3391,6 +3391,40 @@ static void VertexBufferLockRest(void)
IDirect3DVertexBuffer7_Release(buffer);
}
+static void FindDevice(void)
+{
+ D3DFINDDEVICESEARCH search = {0};
+ D3DFINDDEVICERESULT result = {0};
+ HRESULT hr;
+
+ /* Test invalid parameters. */
+ hr = IDirect3D_FindDevice(Direct3D1, NULL, NULL);
+ ok(hr == DDERR_INVALIDPARAMS,
+ "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
+
+ hr = IDirect3D_FindDevice(Direct3D1, NULL, &result);
+ ok(hr == DDERR_INVALIDPARAMS,
+ "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
+
+ hr = IDirect3D_FindDevice(Direct3D1, &search, NULL);
+ ok(hr == DDERR_INVALIDPARAMS,
+ "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
+
+ search.dwSize = 0;
+ result.dwSize = 0;
+
+ hr = IDirect3D_FindDevice(Direct3D1, &search, &result);
+ ok(hr == DDERR_INVALIDPARAMS,
+ "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
+
+ search.dwSize = sizeof(search) + 1;
+ result.dwSize = sizeof(result) + 1;
+
+ hr = IDirect3D_FindDevice(Direct3D1, &search, &result);
+ ok(hr == DDERR_INVALIDPARAMS,
+ "Expected IDirect3D1::FindDevice to return DDERR_INVALIDPARAMS, got 0x%08x\n", hr);
+}
+
START_TEST(d3d)
{
init_function_pointers();
@@ -3425,6 +3459,7 @@ START_TEST(d3d)
Direct3D1Test();
TextureLoadTest();
ViewportTest();
+ FindDevice();
D3D1_releaseObjects();
}
More information about the wine-cvs
mailing list