diff options
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 3 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/html/htmlreqifreader.cxx | 9 |
3 files changed, 27 insertions, 0 deletions
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 9fe827bb00d9..9843e4999f44 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -1299,7 +1299,10 @@ void OleComponent::StoreOwnTmpIfNecessary() GUID aCLSID; hr = m_pNativeImpl->m_pOleObject->GetUserClassID( &aCLSID ); if ( FAILED( hr ) ) + { + SAL_WARN("embeddedobj.ole", "OleComponent::StoreOwnTmpIfNecessary: GetUserClassID() failed"); throw io::IOException(); // TODO + } hr = WriteClassStg( m_pNativeImpl->m_pIStorage, aCLSID ); if ( FAILED( hr ) ) diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index 7f5002ec2772..fddf46d6e658 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -768,6 +768,21 @@ void OleEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStor sal_Int32 nStreamMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; uno::Reference< io::XStream > xNewOwnStream = xNewParentStorage->openStreamElement( aNewName, nStreamMode ); + + uno::Reference<io::XSeekable> xNewSeekable (xNewOwnStream, uno::UNO_QUERY); + if (xNewSeekable.is() && xNewSeekable->getLength() == 0) + { + uno::Reference<io::XSeekable> xOldSeekable(m_xObjectStream, uno::UNO_QUERY); + if (xOldSeekable.is() && xOldSeekable->getLength() > 0) + { + SAL_WARN("embeddedobj.ole", "OleEmbeddedObject::SwitchOwnPersistence: empty new stream, reusing old one"); + uno::Reference<io::XInputStream> xInput = m_xObjectStream->getInputStream(); + uno::Reference<io::XOutputStream> xOutput = xNewOwnStream->getOutputStream(); + comphelper::OStorageHelper::CopyInputToOutput(xInput, xOutput); + xNewSeekable->seek(0); + } + } + SAL_WARN_IF( !xNewOwnStream.is(), "embeddedobj.ole", "The method can not return empty reference!" ); SwitchOwnPersistence( xNewParentStorage, xNewOwnStream, aNewName ); diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx index 40c932ad6332..c0a3196bb018 100644 --- a/sw/source/filter/html/htmlreqifreader.cxx +++ b/sw/source/filter/html/htmlreqifreader.cxx @@ -142,6 +142,15 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei // Read Data. if (nSize > xOle2Presentation->remainingSize()) return false; + + if (nSize <= 64) + { + SAL_WARN("sw.html", + "ParseOLE2Presentation: ignoring potentially broken small preview: size is " + << nSize); + return false; + } + std::vector<char> aBuffer(nSize); xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size()); rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size()); |