From 8ce77cbd706ffd60dfcd79d82779025ef8d6782c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 11 Jun 2021 11:06:11 +0100 Subject: cid#1473844 Untrusted loop bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and cid#1474351 Untrusted loop bound cid#1474118 Untrusted loop bound this time without second guessing the original intent Change-Id: Iaa6b636a08ed29feaf709fbcbac7deac761a0fc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117045 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sc/source/filter/excel/impop.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 1c107d4ad092..988ec3fbf65e 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -878,8 +878,14 @@ void ImportExcel::Mulrk() XclAddress aXclPos; aIn >> aXclPos; - for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol ) + XclAddress aCurrXclPos(aXclPos); + while (true) { + if (aXclPos.mnCol > aCurrXclPos.mnCol) + break; + if (aIn.GetRecLeft() <= 2) + break; + sal_uInt16 nXF = aIn.ReaduInt16(); sal_Int32 nRkNum = aIn.ReadInt32(); @@ -889,6 +895,7 @@ void ImportExcel::Mulrk() GetXFRangeBuffer().SetXF( aScPos, nXF ); GetDocImport().setNumericCell(aScPos, XclTools::GetDoubleFromRK(nRkNum)); } + ++aCurrXclPos.mnCol; } } @@ -915,13 +922,20 @@ void ImportExcel::Mulblank() XclAddress aXclPos; aIn >> aXclPos; - for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol ) + XclAddress aCurrXclPos(aXclPos); + while (true) { + if (aXclPos.mnCol > aCurrXclPos.mnCol) + break; + if (aIn.GetRecLeft() <= 2) + break; + sal_uInt16 nXF = aIn.ReaduInt16(); ScAddress aScPos( ScAddress::UNINITIALIZED ); if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) ) GetXFRangeBuffer().SetBlankXF( aScPos, nXF ); + ++aCurrXclPos.mnCol; } } -- cgit