Huw Davies : oleaut32: [restricted] members with negative dispids may still be called.

Alexandre Julliard julliard at winehq.org
Tue Feb 7 15:53:57 CST 2012


Module: wine
Branch: master
Commit: 0425a110d92ba61fcb3638443bc7782c9dbd7cde
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0425a110d92ba61fcb3638443bc7782c9dbd7cde

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Feb  7 14:28:05 2012 +0000

oleaut32: [restricted] members with negative dispids may still be called.

---

 dlls/oleaut32/tests/tmarshal.c         |   38 ++++++++++++++++++++++++++++++++
 dlls/oleaut32/tests/tmarshal.idl       |    6 +++++
 dlls/oleaut32/tests/tmarshal_dispids.h |    2 +
 dlls/oleaut32/typelib.c                |    7 +++++-
 4 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
index 2fbc2e0..e261464 100644
--- a/dlls/oleaut32/tests/tmarshal.c
+++ b/dlls/oleaut32/tests/tmarshal.c
@@ -660,6 +660,20 @@ static HRESULT WINAPI Widget_put_prop_req_arg(
     return S_OK;
 }
 
+static HRESULT WINAPI Widget_restrict(IWidget* iface, INT *i)
+{
+    trace("restrict\n");
+    *i = DISPID_TM_RESTRICTED;
+    return S_OK;
+}
+
+static HRESULT WINAPI Widget_neg_restrict(IWidget* iface, INT *i)
+{
+    trace("neg_restrict\n");
+    *i = DISPID_TM_NEG_RESTRICTED;
+    return S_OK;
+}
+
 static const struct IWidgetVtbl Widget_VTable =
 {
     Widget_QueryInterface,
@@ -696,6 +710,8 @@ static const struct IWidgetVtbl Widget_VTable =
     Widget_ByRefUInt,
     Widget_put_prop_opt_arg,
     Widget_put_prop_req_arg,
+    Widget_restrict,
+    Widget_neg_restrict
 };
 
 static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject)
@@ -1511,6 +1527,28 @@ static void test_typelibmarshal(void)
     ok_ole_success(hr, ITypeInfo_Invoke);
     VariantClear(&varresult);
 
+    /* restricted member */
+    dispparams.cNamedArgs = 0;
+    dispparams.rgdispidNamedArgs = NULL;
+    dispparams.cArgs = 0;
+    dispparams.rgvarg = NULL;
+    VariantInit(&varresult);
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_RESTRICTED, &IID_NULL, 0x40c, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
+    ok( hr == DISP_E_MEMBERNOTFOUND, "got %08x\n", hr );
+    VariantClear(&varresult);
+
+    /* restricted member with -ve memid (not restricted) */
+    dispparams.cNamedArgs = 0;
+    dispparams.rgdispidNamedArgs = NULL;
+    dispparams.cArgs = 0;
+    dispparams.rgvarg = NULL;
+    VariantInit(&varresult);
+    hr = IDispatch_Invoke(pDispatch, DISPID_TM_NEG_RESTRICTED, &IID_NULL, 0x40c, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok(V_VT(&varresult) == VT_I4, "got %x\n", V_VT(&varresult));
+    ok(V_I4(&varresult) == DISPID_TM_NEG_RESTRICTED, "got %x\n", V_I4(&varresult));
+    VariantClear(&varresult);
+
     IDispatch_Release(pDispatch);
     IWidget_Release(pWidget);
 
diff --git a/dlls/oleaut32/tests/tmarshal.idl b/dlls/oleaut32/tests/tmarshal.idl
index 30b6d8f..88c13bf 100644
--- a/dlls/oleaut32/tests/tmarshal.idl
+++ b/dlls/oleaut32/tests/tmarshal.idl
@@ -149,6 +149,12 @@ library TestTypelib
 
         [id(DISPID_TM_PROP_REQ_ARG), propput]
         HRESULT prop_req_arg([in] INT req, [in] INT i);
+
+        [id(DISPID_TM_RESTRICTED), restricted]
+        HRESULT restrict([out, retval] INT *i);
+
+        [id(DISPID_TM_NEG_RESTRICTED), restricted]
+        HRESULT neg_restrict([out, retval] INT *i);
     }
 
     [
diff --git a/dlls/oleaut32/tests/tmarshal_dispids.h b/dlls/oleaut32/tests/tmarshal_dispids.h
index 0e49505..8570fe9 100644
--- a/dlls/oleaut32/tests/tmarshal_dispids.h
+++ b/dlls/oleaut32/tests/tmarshal_dispids.h
@@ -41,6 +41,8 @@
 #define DISPID_TM_PROP_OPT_ARG 22
 #define DISPID_TM_PROP_REQ_ARG 23
 #define DISPID_TM_VARCARRAY 24
+#define DISPID_TM_RESTRICTED 25
+#define DISPID_TM_NEG_RESTRICTED -26
 
 #define DISPID_NOA_BSTRRET 1
 #define DISPID_NOA_ERROR 2
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 07e294b..95cdc36 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -6241,6 +6241,11 @@ DispCallFunc(
 #endif
 }
 
+static inline BOOL func_restricted( const FUNCDESC *desc )
+{
+    return (desc->wFuncFlags & FUNCFLAG_FRESTRICTED) && (desc->memid >= 0);
+}
+
 #define INVBUF_ELEMENT_SIZE \
     (sizeof(VARIANTARG) + sizeof(VARIANTARG) + sizeof(VARIANTARG *) + sizeof(VARTYPE))
 #define INVBUF_GET_ARG_ARRAY(buffer, params) (buffer)
@@ -6297,7 +6302,7 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
         pFuncInfo = &This->funcdescs[fdc];
         if ((memid == pFuncInfo->funcdesc.memid) &&
             (wFlags & pFuncInfo->funcdesc.invkind) &&
-            (pFuncInfo->funcdesc.wFuncFlags & FUNCFLAG_FRESTRICTED) == 0)
+            !func_restricted( &pFuncInfo->funcdesc ))
             break;
     }
 




More information about the wine-cvs mailing list