From 209cc5c211260a6c20cc6fb5ac02fd5a88100314 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 4 Jul 2017 15:22:23 +0200 Subject: Set error on more than max params (255) per function Parameter count is size byte, so.. SUM(1,1,1,...) with 256 arguments resulted in 0 (uint8 wrapping around). Change-Id: Ib9997ad0d0d13d4c5171f276148b6c5cad570d5b --- formula/source/core/api/FormulaCompiler.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'formula') diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 2f82f3b022a6..389b2e719350 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1490,7 +1490,7 @@ void FormulaCompiler::Factor() } else SetError( FormulaError::PairExpected); - sal_uInt8 nSepCount = 0; + sal_uInt32 nSepCount = 0; const sal_uInt16 nSepPos = maArrIterator.GetIndex() - 1; // separator position, if any if( !bNoParam ) { @@ -1500,6 +1500,8 @@ void FormulaCompiler::Factor() NextToken(); CheckSetForceArrayParameter( mpToken, nSepCount); nSepCount++; + if (nSepCount > FORMULA_MAXPARAMS) + SetError( FormulaError::CodeOverflow); eOp = Expression(); } } @@ -1597,7 +1599,7 @@ void FormulaCompiler::Factor() } else SetError( FormulaError::PairExpected); - sal_uInt8 nSepCount = 0; + sal_uInt32 nSepCount = 0; if( !bNoParam ) { nSepCount++; @@ -1606,6 +1608,8 @@ void FormulaCompiler::Factor() NextToken(); CheckSetForceArrayParameter( mpToken, nSepCount); nSepCount++; + if (nSepCount > FORMULA_MAXPARAMS) + SetError( FormulaError::CodeOverflow); eOp = Expression(); } } -- cgit