Robert Shearman : oleaut32:
Add validation of some more parameters in IFontDisp::Invoke.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jul 27 05:42:24 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: bbdcccd3b75eef9ee13f8ce7e4fe296d4808d416
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=bbdcccd3b75eef9ee13f8ce7e4fe296d4808d416
Author: Robert Shearman <rob at codeweavers.com>
Date: Wed Jul 26 15:02:04 2006 +0100
oleaut32: Add validation of some more parameters in IFontDisp::Invoke.
---
dlls/oleaut32/olefont.c | 35 +++++++++++++++++++++++++++++++++++
dlls/oleaut32/tests/olefont.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c
index 01dd14e..af18428 100644
--- a/dlls/oleaut32/olefont.c
+++ b/dlls/oleaut32/olefont.c
@@ -1402,6 +1402,41 @@ static HRESULT WINAPI OLEFontImpl_Invoke
OLEFontImpl *this = impl_from_IDispatch(iface);
HRESULT hr;
+ /* validate parameters */
+
+ if (!IsEqualIID(riid, &IID_NULL))
+ {
+ ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
+ return DISP_E_UNKNOWNINTERFACE;
+ }
+
+ if (wFlags & DISPATCH_PROPERTYGET)
+ {
+ if (!pVarResult)
+ {
+ ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
+ return DISP_E_PARAMNOTOPTIONAL;
+ }
+ }
+ else if (wFlags & DISPATCH_PROPERTYPUT)
+ {
+ if (!pDispParams)
+ {
+ ERR("null pDispParams not allowed when DISPATCH_PROPERTYPUT specified\n");
+ return DISP_E_PARAMNOTOPTIONAL;
+ }
+ if (pDispParams->cArgs != 1)
+ {
+ ERR("param count for DISPATCH_PROPERTYPUT was %ld instead of 1\n", pDispParams->cArgs);
+ return DISP_E_BADPARAMCOUNT;
+ }
+ }
+ else
+ {
+ ERR("one of DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT must be specified\n");
+ return DISP_E_MEMBERNOTFOUND;
+ }
+
switch (dispIdMember) {
case DISPID_FONT_NAME:
if (wFlags & DISPATCH_PROPERTYGET) {
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c
index 1640f79..423cb4d 100644
--- a/dlls/oleaut32/tests/olefont.c
+++ b/dlls/oleaut32/tests/olefont.c
@@ -425,6 +425,39 @@ void test_GetIDsOfNames(void)
DISPID_FONT_NAME, 0, S_OK,1);
}
+static void test_Invoke(void)
+{
+ IFontDisp *fontdisp;
+ HRESULT hr;
+ VARIANTARG vararg;
+ DISPPARAMS dispparams;
+
+ hr = pOleCreateFontIndirect(NULL, &IID_IFontDisp, (void **)&fontdisp);
+ ok_ole_success(hr, "OleCreateFontIndirect\n");
+
+ V_VT(&vararg) = VT_BOOL;
+ V_BOOL(&vararg) = FALSE;
+ dispparams.cNamedArgs = 0;
+ dispparams.rgdispidNamedArgs = NULL;
+ dispparams.cArgs = 1;
+ dispparams.rgvarg = &vararg;
+ hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_IFontDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
+ ok(hr == DISP_E_UNKNOWNINTERFACE, "IFontDisp_Invoke should have returned DISP_E_UNKNOWNINTERFACE instead of 0x%08lx\n", hr);
+
+ dispparams.cArgs = 0;
+ dispparams.rgvarg = NULL;
+ hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
+ ok(hr == DISP_E_BADPARAMCOUNT, "IFontDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr);
+
+ hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL);
+ ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
+
+ hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
+ ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
+
+ IFontDisp_Release(fontdisp);
+}
+
START_TEST(olefont)
{
hOleaut32 = LoadLibraryA("oleaut32.dll");
@@ -447,4 +480,5 @@ START_TEST(olefont)
test_font_events_disp();
test_GetIDsOfNames();
+ test_Invoke();
}
More information about the wine-cvs
mailing list