Andrew Nguyen : oleaut32: Improve parameter validation in OleLoadPicturePath.
Alexandre Julliard
julliard at winehq.org
Thu May 20 11:03:03 CDT 2010
Module: wine
Branch: master
Commit: dc13339988523e06148037b06b90ffb8070316ac
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dc13339988523e06148037b06b90ffb8070316ac
Author: Andrew Nguyen <anguyen at codeweavers.com>
Date: Wed May 19 22:26:15 2010 -0500
oleaut32: Improve parameter validation in OleLoadPicturePath.
---
dlls/oleaut32/olepicture.c | 5 ++-
dlls/oleaut32/tests/olepicture.c | 72 ++++++++++++++++++++++++++++++++++---
2 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 3f431fd..d9d488f 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -2278,7 +2278,10 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
debugstr_w(szURLorPath), punkCaller, dwReserved, clrReserved,
debugstr_guid(riid), ppvRet);
- if (!ppvRet) return E_POINTER;
+ if (!szURLorPath || !ppvRet)
+ return E_INVALIDARG;
+
+ *ppvRet = NULL;
if (strncmpW(szURLorPath, file, 7) == 0) {
szURLorPath += 7;
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index c8ddc8a..2874804 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -36,6 +36,7 @@
#include <winerror.h>
#include <winnt.h>
+#include <urlmon.h>
#include <wtypes.h>
#include <olectl.h>
#include <objidl.h>
@@ -737,6 +738,64 @@ static void test_get_Type(void)
IPicture_Release(pic);
}
+static void test_OleLoadPicturePath(void)
+{
+ static WCHAR emptyW[] = {0};
+
+ IPicture *pic;
+ HRESULT hres;
+ int i;
+
+ const struct
+ {
+ LPOLESTR szURLorPath;
+ REFIID riid;
+ IPicture **pic;
+ } invalid_parameters[] =
+ {
+ {NULL, NULL, NULL},
+ {NULL, NULL, &pic},
+ {NULL, &IID_IPicture, NULL},
+ {NULL, &IID_IPicture, &pic},
+ {emptyW, NULL, NULL},
+ {emptyW, &IID_IPicture, NULL},
+ };
+
+ for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ {
+ pic = (IPicture *)0xdeadbeef;
+ hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
+ invalid_parameters[i].riid,
+ (void **)invalid_parameters[i].pic);
+ ok(hres == E_INVALIDARG,
+ "[%d] Expected OleLoadPicturePath to return E_INVALIDARG, got 0x%08x\n", i, hres);
+ ok(pic == (IPicture *)0xdeadbeef,
+ "[%d] Expected output pointer to be 0xdeadbeef, got %p\n", i, pic);
+ }
+
+ pic = (IPicture *)0xdeadbeef;
+ hres = OleLoadPicturePath(emptyW, NULL, 0, 0, NULL, (void **)&pic);
+ todo_wine
+ ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
+ hres == E_UNEXPECTED || /* NT4/Win95 */
+ hres == E_FAIL || /* Win95 OSR2 */
+ hres == E_OUTOFMEMORY, /* Win98/Win2k/Win2k3 */
+ "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08x\n", hres);
+ ok(pic == NULL,
+ "Expected the output interface pointer to be NULL, got %p\n", pic);
+
+ pic = (IPicture *)0xdeadbeef;
+ hres = OleLoadPicturePath(emptyW, NULL, 0, 0, &IID_IPicture, (void **)&pic);
+ todo_wine
+ ok(hres == INET_E_UNKNOWN_PROTOCOL || /* XP/Vista+ */
+ hres == E_UNEXPECTED || /* NT4/Win95 */
+ hres == E_FAIL || /* Win95 OSR2 */
+ hres == E_OUTOFMEMORY, /* Win98/Win2k/Win2k3 */
+ "Expected OleLoadPicturePath to return INET_E_UNKNOWN_PROTOCOL, got 0x%08x\n", hres);
+ ok(pic == NULL,
+ "Expected the output interface pointer to be NULL, got %p\n", pic);
+}
+
START_TEST(olepicture)
{
hOleaut32 = GetModuleHandleA("oleaut32.dll");
@@ -761,12 +820,13 @@ START_TEST(olepicture)
test_metafile();
test_enhmetafile();
- test_Invoke();
- test_OleCreatePictureIndirect();
- test_Render();
- test_get_Attributes();
- test_get_Handle();
- test_get_Type();
+ test_Invoke();
+ test_OleCreatePictureIndirect();
+ test_Render();
+ test_get_Attributes();
+ test_get_Handle();
+ test_get_Type();
+ test_OleLoadPicturePath();
}
More information about the wine-cvs
mailing list