summaryrefslogtreecommitdiff
path: root/svtools/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-07-12 16:30:42 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-07-12 18:45:14 +0200
commit52e1a6a3e4d613eeb9313922098b0ba11807fb12 (patch)
treecc3ef1ca5589566a5b327a62c8a56dbbe0f28c8b /svtools/source
parent56dff7b244fb0ef28951193a410dd5c4a3126590 (diff)
use a read-only stream when reading graphic data
EmbeddedObjectRef::GetGraphicStream() creates a writable SvMemoryStream, read the graphics data into it and then returns the stream, which will be afterwards used to decode the graphics. But if the data is broken, incorrect seeking may cause a seek way past the buffer, and since the stream is writable, it would be done and cause problems such as running out of memory. The VersionCompatRead class is one such place that reads size from the stream and then seeks based on the read data. Add SvMemoryStream::MakeReadOnly() that will change the stream to be read-only after the initial read of the data into it. Change-Id: I1d44aabaf73071a691adafa489e65e4f5e3f021d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137002 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'svtools/source')
-rw-r--r--svtools/source/misc/embedhlp.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 809a2b155790..91a591ec8724 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -632,7 +632,7 @@ std::unique_ptr<SvStream> EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) co
if ( xStream.is() )
{
const sal_Int32 nConstBufferSize = 32000;
- std::unique_ptr<SvStream> pStream(new SvMemoryStream( 32000, 32000 ));
+ std::unique_ptr<SvMemoryStream> pStream(new SvMemoryStream( 32000, 32000 ));
try
{
sal_Int32 nRead=0;
@@ -644,6 +644,7 @@ std::unique_ptr<SvStream> EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) co
}
while ( nRead == nConstBufferSize );
pStream->Seek(0);
+ pStream->MakeReadOnly();
return pStream;
}
catch (const uno::Exception&)