ruby-changes:30595
From: nobu <ko1@a...>
Date: Fri, 23 Aug 2013 23:09:55 +0900 (JST)
Subject: [ruby-changes:30595] nobu:r42674 (trunk): win32ole.c: ID overflow
nobu 2013-08-23 23:09:49 +0900 (Fri, 23 Aug 2013) New Revision: 42674 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42674 Log: win32ole.c: ID overflow * ext/win32ole/win32ole.c (GetIDsOfNames): check ID overflow against DISPID, aka LONG, which is always 4 bytes. * ext/win32ole/win32ole.c (Invoke): use ID for method name to get rid of losing upper bits. Modified files: trunk/ext/win32ole/win32ole.c Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 42673) +++ ext/win32ole/win32ole.c (revision 42674) @@ -764,8 +764,10 @@ static HRESULT ( STDMETHODCALLTYPE GetID https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L764 Win32OLEIDispatch* p = (Win32OLEIDispatch*)This; */ char* psz = ole_wc2mb(*rgszNames); // support only one method - *rgDispId = rb_intern(psz); + ID nameid = rb_intern(psz); free(psz); + if ((ID)(DISPID)nameid != nameid) return E_NOINTERFACE; + *rgDispId = (DISPID)nameid; return S_OK; } @@ -785,17 +787,18 @@ static /* [local] */ HRESULT ( STDMETHOD https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L787 int args = pDispParams->cArgs; Win32OLEIDispatch* p = (Win32OLEIDispatch*)This; VALUE* parg = ALLOCA_N(VALUE, args); + ID mid = (ID)dispIdMember; for (i = 0; i < args; i++) { *(parg + i) = ole_variant2val(&pDispParams->rgvarg[args - i - 1]); } if (dispIdMember == DISPID_VALUE) { if (wFlags == DISPATCH_METHOD) { - dispIdMember = rb_intern("call"); + mid = rb_intern("call"); } else if (wFlags & DISPATCH_PROPERTYGET) { - dispIdMember = rb_intern("value"); + mid = rb_intern("value"); } } - v = rb_funcall2(p->obj, dispIdMember, args, parg); + v = rb_funcall2(p->obj, mid, args, parg); ole_val2variant(v, pVarResult); return S_OK; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/