diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-04 03:17:13 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-04 03:34:25 +0100 |
commit | 9bcfb6f06bf5a4708b8858469b4118af4222db5a (patch) | |
tree | 093291d5d72c9099c4fdbc5402b1ca481f7ad1e1 /sc | |
parent | 3e85d9c62c69ee39dd4c6ae7cd556fdf53f5e01d (diff) |
add some more safety checks for row and column import from ODS
Change-Id: Ic714c65cfe93198c462ba55752223f4e60e5aad9
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcoli.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlrowi.cxx | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 5a5d73f66681..f3eca237d1a9 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -833,6 +833,12 @@ void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos, for (SCCOL i = 0; i < nColsRepeated; ++i) { rCurrentPos.SetCol( rCellPos.Col() + i ); + + // it makes no sense to import data after the last supported column + // fdo#58539 & gnome#627150 + if(rCurrentPos.Col() > MAXCOL) + break; + if (i > 0) rTables.AddColumn(false); if (!bIsEmpty) @@ -840,6 +846,12 @@ void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos, for (SCROW j = 0; j < nRepeatedRows; ++j) { rCurrentPos.SetRow( rCellPos.Row() + j ); + + // it makes no sense to import data after last supported row + // fdo#58539 & gnome#627150 + if(rCurrentPos.Row() > MAXROW) + break; + if( (rCurrentPos.Col() == 0) && (j > 0) ) { rTables.AddRow(); diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx index 688300e27df3..ed892944e65a 100644 --- a/sc/source/filter/xml/xmlcoli.cxx +++ b/sc/source/filter/xml/xmlcoli.cxx @@ -66,7 +66,8 @@ ScXMLTableColContext::ScXMLTableColContext( ScXMLImport& rImport, { case XML_TOK_TABLE_COL_ATTR_REPEATED: { - nColCount = sValue.toInt32(); + nColCount = std::max<sal_Int32>(sValue.toInt32(), 1); + nColCount = std::min<sal_Int32>(nColCount, MAXCOLCOUNT); } break; case XML_TOK_TABLE_COL_ATTR_STYLE_NAME: diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx index 67d1f23ae43a..a4434e1b2a37 100644 --- a/sc/source/filter/xml/xmlrowi.cxx +++ b/sc/source/filter/xml/xmlrowi.cxx @@ -83,6 +83,7 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport, case XML_TOK_TABLE_ROW_ATTR_REPEATED: { nRepeatedRows = std::max( sValue.toInt32(), (sal_Int32) 1 ); + nRepeatedRows = std::min( nRepeatedRows, MAXROWCOUNT ); } break; case XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME: |