summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-30 17:01:23 +0100
committerEike Rathke <erack@redhat.com>2015-09-30 21:05:26 +0000
commit648a60212c3429ea8b1794247bb4d5fb832e3cc5 (patch)
tree11bf8c64f129703ab32c1b39ed12eb9cabb66432
parent6e4dfd1b8b67aafe1a83aac3a329e6b9ff091e57 (diff)
don't believe xls wrt size to reserve
(cherry picked from commit 358ca9eaa3d85236047a7a2781e38f57209c2858) Change-Id: Id9864f199e270d13d801348b12f1e94dd80558c7 Reviewed-on: https://gerrit.libreoffice.org/19043 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/qa/unit/data/xls/pass/crash-1.xlsbin0 -> 4096 bytes
-rw-r--r--sc/source/filter/excel/xicontent.cxx11
2 files changed, 8 insertions, 3 deletions
diff --git a/sc/qa/unit/data/xls/pass/crash-1.xls b/sc/qa/unit/data/xls/pass/crash-1.xls
new file mode 100644
index 000000000000..724bfc1a6f14
--- /dev/null
+++ b/sc/qa/unit/data/xls/pass/crash-1.xls
Binary files differ
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 79c78ead74c9..bb17b6683867 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -75,10 +75,15 @@ XclImpSst::XclImpSst( const XclImpRoot& rRoot ) :
void XclImpSst::ReadSst( XclImpStream& rStrm )
{
rStrm.Ignore( 4 );
- sal_uInt32 nStrCount(0);
- rStrm >> nStrCount;
+ sal_uInt32 nStrCount = rStrm.ReaduInt32();
+ auto nBytesAvailable = rStrm.GetRecLeft();
+ if (nStrCount > nBytesAvailable)
+ {
+ SAL_WARN("sc.filter", "xls claimed to have " << nStrCount << " strings, but only " << nBytesAvailable << " bytes available, truncating");
+ nStrCount = nBytesAvailable;
+ }
maStrings.clear();
- maStrings.reserve( static_cast< size_t >( nStrCount ) );
+ maStrings.reserve(nStrCount);
while( (nStrCount > 0) && rStrm.IsValid() )
{
XclImpString aString;