basic/source/runtime/methods.cxx | 24 ++---------------------- filter/source/msfilter/svdfppt.cxx | 14 ++++++++++++-- sd/qa/unit/data/ppt/pass/hang-1.ppt |binary sd/source/filter/ppt/pptin.cxx | 7 ++++++- 4 files changed, 20 insertions(+), 25 deletions(-)
New commits: commit cadac8400a018c8c566379f7767ea5edff78523d Author: Caolán McNamara <caol...@redhat.com> Date: Wed Aug 26 12:35:01 2015 +0100 don't hang on unreachable record ends Change-Id: I288f7ff0327831603eda6e827c8acbae678dfaff diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index f5b7931..8199766 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -4061,8 +4061,18 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd } rSlideHd.SeekToContent( rIn ); + + auto nEndRecPos = rSlideHd.GetRecEndFilePos(); + auto nStreamLen = rIn.Tell() + rIn.remainingSize(); + if (nEndRecPos > nStreamLen) + { + SAL_WARN("filter.ms", "Parsing error: " << nStreamLen << + " max end pos, but " << nEndRecPos << " claimed, truncating"); + nEndRecPos = nStreamLen; + } + DffRecordHeader aTxMasterStyleHd; - while ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) + while (rIn.Tell() < nEndRecPos) { ReadDffRecordHeader( rIn, aTxMasterStyleHd ); if ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) @@ -4070,7 +4080,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd else aTxMasterStyleHd.SeekToEndOfRecord( rIn ); } - while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < rSlideHd.GetRecEndFilePos() ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized + while ( ( aTxMasterStyleHd.nRecType == PPT_PST_TxMasterStyleAtom ) && ( rIn.Tell() < nEndRecPos ) ) //TODO: aTxMasterStyleHd may be used without having been properly initialized { sal_uInt32 nInstance = aTxMasterStyleHd.nRecInstance; if ( ( nInstance < PPT_STYLESHEETENTRYS ) && diff --git a/sd/qa/unit/data/ppt/pass/hang-1.ppt b/sd/qa/unit/data/ppt/pass/hang-1.ppt new file mode 100644 index 0000000..d30cb84 Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-1.ppt differ diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index af1588f..5f92ae8 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -821,7 +821,12 @@ bool ImplSdPPTImport::Import() } break; } - aHd.SeekToEndOfRecord( rStCtrl ); + bool bSuccess = aHd.SeekToEndOfRecord(rStCtrl); + if (!bSuccess) + { + SAL_WARN("filter.ms", "Count not seek to end of record"); + break; + } } } rStCtrl.Seek( nFPosMerk ); commit 94a52f9ffafdf9c6e64ddf1a3587f21a272f2e62 Author: Damjan Jovanovic <dam...@apache.org> Date: Wed Aug 26 02:10:46 2015 +0000 Resolves: #i117989# Basic functions return wrong results for dates <1900-1-1 Also extended our spreadsheeet test to search through more columns, open spreadsheets with macros enabled, and added a test for the the Year(), Month(), Day(), Hour(), Minute(), and Second() functions comparing Calc's formulas vs StarBasic's runtime functions. Found-by: villeroy Patch-by: Damjan Jovanovic (cherry picked from commit a68493266e9212119f31e58c256f00fb9bcc8d20) Change-Id: I8f2115c623a1d35db5b7fc8184a9118c3eca6fcd diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index d240705..b7dcc98 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1820,17 +1820,9 @@ RTLFUNC(Val) sal_Int16 implGetDateDay( double aDate ) { aDate -= 2.0; // standardize: 1.1.1900 => 0.0 + aDate = floor( aDate ); Date aRefDate( 1, 1, 1900 ); - if ( aDate >= 0.0 ) - { - aDate = floor( aDate ); - aRefDate += static_cast<long>(aDate); - } - else - { - aDate = ceil( aDate ); - aRefDate -= static_cast<long>(-1.0 * aDate); - } + aRefDate += static_cast<long>(aDate); sal_Int16 nRet = (sal_Int16)( aRefDate.GetDay() ); return nRet; @@ -2270,10 +2262,6 @@ RTLFUNC(Year) sal_Int16 implGetHour( double dDate ) { - if( dDate < 0.0 ) - { - dDate *= -1.0; - } double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5); @@ -2333,10 +2321,6 @@ RTLFUNC(Month) sal_Int16 implGetSecond( double dDate ) { - if( dDate < 0.0 ) - { - dDate *= -1.0; - } double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5); @@ -5016,10 +5000,6 @@ bool implDateTimeSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, sal_Int16 implGetMinute( double dDate ) { - if( dDate < 0.0 ) - { - dDate *= -1.0; - } double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits