diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-01-26 16:01:57 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-01-26 16:02:53 +0000 |
commit | f85fb724d52a0fff9c64365cd202ae8975492c05 (patch) | |
tree | 3336bb587b29b84875e5538f7b14a0beab378df4 /filter | |
parent | Adapt odk/examples to incompatibly changed (unpublished) API (diff) | |
download | core-f85fb724d52a0fff9c64365cd202ae8975492c05.tar.gz core-f85fb724d52a0fff9c64365cd202ae8975492c05.zip |
ofz: check eps seeks are sane and succeeded
Change-Id: I0eb45e1c1ffd91682ed0ce6a6a74eab54666d715
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/ieps/ieps.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index f50f9968cab0..912be13253f3 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -519,6 +519,14 @@ void MakePreview(sal_uInt8* pBuf, sal_uInt32 nBytesRead, rGraphic = aMtf; } +namespace +{ + bool checkSeek(SvStream &rSt, sal_uInt32 nOffset) + { + const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize()); + return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset); + } +} //================== GraphicImport - the exported function ================ @@ -549,10 +557,9 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) if ( nSizeWMF ) { - if ( nPosWMF != 0 ) + if (nPosWMF && checkSeek(rStream, nOrigPos + nPosWMF)) { - rStream.Seek( nOrigPos + nPosWMF ); - if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::WMF ) == ERRCODE_NONE ) + if (GraphicConverter::Import(rStream, aGraphic, ConvertDataFormat::WMF) == ERRCODE_NONE) bHasPreview = bRetValue = true; } } @@ -562,9 +569,8 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) // else we have to get the tiff grafix - if ( nPosTIFF && nSizeTIFF ) + if (nPosTIFF && nSizeTIFF && checkSeek(rStream, nOrigPos + nPosTIFF)) { - rStream.Seek( nOrigPos + nPosTIFF ); if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE ) { MakeAsMeta(aGraphic); |