diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-19 23:54:34 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-10-20 08:00:23 +0200 |
commit | a3143aa0dec78177e522858fbf786494c75512a0 (patch) | |
tree | 7e51218ed127dba4b143e9133b11de3498261c63 /extensions | |
parent | 9d936de849f1d2267dc733d38ff66d66490b04f7 (diff) |
tdf#120703 (PVS): properly handle BSTR; fix enum comparison
V505 The 'alloca' function is used inside the loop. This can quickly overflow
stack.
V745 A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string.
Consider using 'SysAllocString' function.
V768 The variable 'mnVersion' is of enum type. It is odd that it is used as a
variable of a Boolean-type.
Change-Id: If7533483a53467b6901d1f39411a634d77bbd840
Reviewed-on: https://gerrit.libreoffice.org/62033
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/activex/SOActiveX.cxx | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index ee74dfdaa0fd..f13d58564bdc 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -354,18 +354,17 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/ return hr; } - USES_CONVERSION; for( unsigned long ind = 0; ind < aNum; ind++ ) { // all information from the 'object' tag is in strings - if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) ) + if (aVal[ind].vt == VT_BSTR && !wcscmp(aPropNames[ind].pstrName, L"src")) { mCurFileUrl = wcsdup( aVal[ind].bstrVal ); } else if( aVal[ind].vt == VT_BSTR - && !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) ) + && !wcscmp(aPropNames[ind].pstrName, L"readonly")) { - if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) ) + if (!wcscmp(aVal[ind].bstrVal, L"true")) { // the default value mbViewOnly = TRUE; @@ -385,9 +384,16 @@ STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/ return hr; mbReadyForActivation = FALSE; - hr = CBindStatusCallback<CSOActiveX>::Download( this, &CSOActiveX::CallbackCreateXInputStream, const_cast<OLECHAR *>(mCurFileUrl), m_spClientSite, FALSE ); - if ( hr == MK_S_ASYNCHRONOUS ) - hr = S_OK; + if (BSTR bStrUrl = SysAllocString(mCurFileUrl)) + { + hr = CBindStatusCallback<CSOActiveX>::Download( + this, &CSOActiveX::CallbackCreateXInputStream, bStrUrl, m_spClientSite, FALSE); + SysFreeString(bStrUrl); + if (hr == MK_S_ASYNCHRONOUS) + hr = S_OK; + } + else + hr = E_OUTOFMEMORY; if ( !SUCCEEDED( hr ) ) { @@ -912,23 +918,22 @@ SOVersion CSOActiveX::GetVersionConnected() if( SUCCEEDED( hr ) && aOfficeVersion.vt == VT_BSTR ) { - USES_CONVERSION; - if( !strcmp( OLE2T( aOfficeName.bstrVal ), "StarOffice" ) ) + if (!wcscmp(aOfficeName.bstrVal, L"StarOffice")) { - if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.1", 3 ) ) + if (!wcsncmp(aOfficeVersion.bstrVal, L"6.1", 3)) bResult = SO_61; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.0", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"6.0", 3)) bResult = SO_60; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "5.2", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"5.2", 3)) bResult = SO_52; else bResult = SO_UNKNOWN; } else // OpenOffice { - if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.1", 3 ) ) + if (!wcsncmp(aOfficeVersion.bstrVal, L"1.1", 3)) bResult = OO_11; - else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.0", 3 ) ) + else if (!wcsncmp(aOfficeVersion.bstrVal, L"1.0", 3)) bResult = OO_10; else bResult = OO_UNKNOWN; @@ -1030,7 +1035,7 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di ) } } - if( !mnVersion ) + if (mnVersion == SO_NOT_DETECTED) { OutputError_Impl( mOffWin, CS_E_INVALID_VERSION ); return E_FAIL; |