Skip to content

Commit

Permalink
Bug 1393600: Prevent mismatches between the handler's expected interf…
Browse files Browse the repository at this point in the history
…ace and the one being provided by content; r=jimm

MozReview-Commit-ID: 4yQENc7i4LS
  • Loading branch information
dblohm7 committed Sep 21, 2017
1 parent 5baca5e commit 35c65ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
22 changes: 16 additions & 6 deletions ipc/mscom/Interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,31 @@ Interceptor::GetClassForHandler(DWORD aDestContext, void* aDestContextPtr,
return mEventSink->GetHandler(WrapNotNull(aHandlerClsid));
}

REFIID
Interceptor::MarshalAs(REFIID aIid) const
{
#if defined(MOZ_MSCOM_REMARSHAL_NO_HANDLER)
return IsCallerExternalProcess() ? aIid : mEventSink->MarshalAs(aIid);
#else
return mEventSink->MarshalAs(aIid);
#endif // defined(MOZ_MSCOM_REMARSHAL_NO_HANDLER)
}

HRESULT
Interceptor::GetUnmarshalClass(REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags,
CLSID* pCid)
{
return mStdMarshal->GetUnmarshalClass(riid, pv, dwDestContext, pvDestContext,
mshlflags, pCid);
return mStdMarshal->GetUnmarshalClass(MarshalAs(riid), pv, dwDestContext,
pvDestContext, mshlflags, pCid);
}

HRESULT
Interceptor::GetMarshalSizeMax(REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags,
DWORD* pSize)
{
HRESULT hr = mStdMarshal->GetMarshalSizeMax(riid, pv, dwDestContext,
HRESULT hr = mStdMarshal->GetMarshalSizeMax(MarshalAs(riid), pv, dwDestContext,
pvDestContext, mshlflags, pSize);
if (FAILED(hr)) {
return hr;
Expand Down Expand Up @@ -269,7 +279,7 @@ Interceptor::MarshalInterface(IStream* pStm, REFIID riid, void* pv,

#endif // defined(MOZ_MSCOM_REMARSHAL_NO_HANDLER)

hr = mStdMarshal->MarshalInterface(pStm, riid, pv, dwDestContext,
hr = mStdMarshal->MarshalInterface(pStm, MarshalAs(riid), pv, dwDestContext,
pvDestContext, mshlflags);
if (FAILED(hr)) {
return hr;
Expand Down Expand Up @@ -466,7 +476,7 @@ Interceptor::GetInitialInterceptorForIID(detail::LiveSetAutoLock& aLiveSetLock,
hr = PublishTarget(aLiveSetLock, unkInterceptor, aTargetIid, Move(aTarget));
ENSURE_HR_SUCCEEDED(hr);

if (mEventSink->MarshalAs(aTargetIid) == aTargetIid) {
if (MarshalAs(aTargetIid) == aTargetIid) {
hr = unkInterceptor->QueryInterface(aTargetIid, aOutInterceptor);
ENSURE_HR_SUCCEEDED(hr);
return hr;
Expand Down Expand Up @@ -499,7 +509,7 @@ Interceptor::GetInterceptorForIID(REFIID aIid, void** aOutInterceptor)
return S_OK;
}

REFIID interceptorIid = mEventSink->MarshalAs(aIid);
REFIID interceptorIid = MarshalAs(aIid);

RefPtr<IUnknown> unkInterceptor;
IUnknown* interfaceForQILog = nullptr;
Expand Down
1 change: 1 addition & 0 deletions ipc/mscom/Interceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class Interceptor final : public WeakReferenceSupport
HRESULT ThreadSafeQueryInterface(REFIID aIid,
IUnknown** aOutInterface) override;
HRESULT CreateInterceptor(REFIID aIid, IUnknown* aOuter, IUnknown** aOutput);
REFIID MarshalAs(REFIID aIid) const;
HRESULT PublishTarget(detail::LiveSetAutoLock& aLiveSetLock,
RefPtr<IUnknown> aInterceptor,
REFIID aTargetIid,
Expand Down
4 changes: 2 additions & 2 deletions ipc/mscom/oop/Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Handler::GetUnmarshalClass(REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags,
CLSID* pCid)
{
return mUnmarshal->GetUnmarshalClass(riid, pv, dwDestContext, pvDestContext,
mshlflags, pCid);
return mUnmarshal->GetUnmarshalClass(MarshalAs(riid), pv, dwDestContext,
pvDestContext, mshlflags, pCid);
}

HRESULT
Expand Down

0 comments on commit 35c65ef

Please sign in to comment.