diff options
author | Noel <noelgrandin@gmail.com> | 2020-11-16 15:58:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-18 06:54:06 +0100 |
commit | 8c9a4ff511a3b1d84a7a6d08a1b153c07f164abb (patch) | |
tree | 9bf5454718b572c33ccea18ae0c7cd6743d4381d /sd | |
parent | 6610266bde5a836d8ee1bfec6c8ab9d30c1d2529 (diff) |
throw exception in SvStream when reading past end of file
to avoid chasing weird problems where we read past the end
of file, which leads to random data in the variable we read into.
I expect a couple of possible regressions from this change
(1) memory leaks caused by non-exception-safe memory handling.
Of which there should not be much because we're pretty good
about using smart pointer classes these days.
(2) Broken files which used to load, will no longer do so.
These will have to be debugged by putting a breakpoint
on the SvStreamEOFException constructor, and examining
the backtrace to see where we should be catching and ignoring
the exception to make the code continue to handle such broken
files.
Change-Id: I351be031bb083a3484a9a1b650a58892700e6fb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105936
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/ppt/fail/crash-1.ppt (renamed from sd/qa/unit/data/ppt/pass/crash-1.ppt) | bin | 7677 -> 7677 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-14.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-14.ppt) | bin | 7680 -> 7680 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-15.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-15.ppt) | bin | 7680 -> 7680 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-19.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-19.ppt) | bin | 7680 -> 7680 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-21.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-21.ppt) | bin | 7659 -> 7659 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-4.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-4.ppt) | bin | 7712 -> 7712 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-6.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-6.ppt) | bin | 7712 -> 7712 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/hang-8.ppt (renamed from sd/qa/unit/data/ppt/pass/hang-8.ppt) | bin | 7712 -> 7712 bytes | |||
-rw-r--r-- | sd/qa/unit/data/ppt/fail/ofz14989-1.ppt (renamed from sd/qa/unit/data/ppt/pass/ofz14989-1.ppt) | bin | 60108 -> 60108 bytes | |||
-rw-r--r-- | sd/source/filter/ppt/pptin.cxx | 15 |
10 files changed, 11 insertions, 4 deletions
diff --git a/sd/qa/unit/data/ppt/pass/crash-1.ppt b/sd/qa/unit/data/ppt/fail/crash-1.ppt Binary files differindex 5d1a04b33cea..5d1a04b33cea 100644 --- a/sd/qa/unit/data/ppt/pass/crash-1.ppt +++ b/sd/qa/unit/data/ppt/fail/crash-1.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-14.ppt b/sd/qa/unit/data/ppt/fail/hang-14.ppt Binary files differindex 8dd397bb3649..8dd397bb3649 100644 --- a/sd/qa/unit/data/ppt/pass/hang-14.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-14.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-15.ppt b/sd/qa/unit/data/ppt/fail/hang-15.ppt Binary files differindex b93255a7fd1c..b93255a7fd1c 100644 --- a/sd/qa/unit/data/ppt/pass/hang-15.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-15.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-19.ppt b/sd/qa/unit/data/ppt/fail/hang-19.ppt Binary files differindex 942a58a66c5d..942a58a66c5d 100644 --- a/sd/qa/unit/data/ppt/pass/hang-19.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-19.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-21.ppt b/sd/qa/unit/data/ppt/fail/hang-21.ppt Binary files differindex 99cf49f8d1e5..99cf49f8d1e5 100644 --- a/sd/qa/unit/data/ppt/pass/hang-21.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-21.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-4.ppt b/sd/qa/unit/data/ppt/fail/hang-4.ppt Binary files differindex f5aa24752180..f5aa24752180 100644 --- a/sd/qa/unit/data/ppt/pass/hang-4.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-4.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-6.ppt b/sd/qa/unit/data/ppt/fail/hang-6.ppt Binary files differindex f5aa24752180..f5aa24752180 100644 --- a/sd/qa/unit/data/ppt/pass/hang-6.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-6.ppt diff --git a/sd/qa/unit/data/ppt/pass/hang-8.ppt b/sd/qa/unit/data/ppt/fail/hang-8.ppt Binary files differindex 0f52bd5d249d..0f52bd5d249d 100644 --- a/sd/qa/unit/data/ppt/pass/hang-8.ppt +++ b/sd/qa/unit/data/ppt/fail/hang-8.ppt diff --git a/sd/qa/unit/data/ppt/pass/ofz14989-1.ppt b/sd/qa/unit/data/ppt/fail/ofz14989-1.ppt Binary files differindex b470ebecdb49..b470ebecdb49 100644 --- a/sd/qa/unit/data/ppt/pass/ofz14989-1.ppt +++ b/sd/qa/unit/data/ppt/fail/ofz14989-1.ppt diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index 02a2b544215d..254da0754bba 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -792,7 +792,8 @@ bool ImplSdPPTImport::Import() while( ( rStCtrl.GetError() == ERRCODE_NONE ) && ( rStCtrl.Tell() < nEndRecPos ) ) { DffRecordHeader aHd; - ReadDffRecordHeader( rStCtrl, aHd ); + if (!ReadDffRecordHeader( rStCtrl, aHd )) + break; switch( aHd.nRecType ) { case PPT_PST_PPDrawing : @@ -2770,9 +2771,15 @@ ImplSdPPTImport::ReadFormControl( tools::SvRef<SotStorage>& rSrc1, css::uno::Ref extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool ImportPPT( SdDrawDocument* pDocument, SvStream& rDocStream, SotStorage& rStorage, SfxMedium& rMedium ) { - std::unique_ptr<SdPPTImport> pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium )); - bool bRet = pImport->Import(); - return bRet; + try + { + std::unique_ptr<SdPPTImport> pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium )); + return pImport->Import(); + } + catch(SvStreamEOFException&) + { + return false; + } } extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportPPT(SvStream &rStream) |