summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/tools/stream.hxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 897af71d5021..44f69a400b53 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -676,6 +676,10 @@ public:
void SetBuffer( void* pBuf, std::size_t nSize, std::size_t nEOF );
void ObjectOwnsMemory( bool bOwn ) { bOwnsData = bOwn; }
+ /// Makes the stream read-only after it was (possibly) initially writable,
+ /// without having to copy the data or change buffers.
+ /// @since LibreOffice 7.5
+ void MakeReadOnly();
void SetResizeOffset( std::size_t nNewResize ) { nResize = nNewResize; }
virtual sal_uInt64 TellEnd() override { FlushBuffer(); return nEndOfData; }
};