Kaydet (Commit) 1d1bdfd9 authored tarafından Eike Rathke's avatar Eike Rathke Kaydeden (comit) Markus Mohrhard

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).

(cherry picked from commit 209cc5c2)

Change-Id: Ib9997ad0d0d13d4c5171f276148b6c5cad570d5b
Reviewed-on: https://gerrit.libreoffice.org/39506Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 747be681
...@@ -1511,7 +1511,7 @@ void FormulaCompiler::Factor() ...@@ -1511,7 +1511,7 @@ void FormulaCompiler::Factor()
} }
else else
SetError( FormulaError::PairExpected); SetError( FormulaError::PairExpected);
sal_uInt8 nSepCount = 0; sal_uInt32 nSepCount = 0;
const sal_uInt16 nSepPos = pArr->nIndex - 1; // separator position, if any const sal_uInt16 nSepPos = pArr->nIndex - 1; // separator position, if any
if( !bNoParam ) if( !bNoParam )
{ {
...@@ -1521,6 +1521,8 @@ void FormulaCompiler::Factor() ...@@ -1521,6 +1521,8 @@ void FormulaCompiler::Factor()
NextToken(); NextToken();
CheckSetForceArrayParameter( mpToken, nSepCount); CheckSetForceArrayParameter( mpToken, nSepCount);
nSepCount++; nSepCount++;
if (nSepCount > FORMULA_MAXPARAMS)
SetError( FormulaError::CodeOverflow);
eOp = Expression(); eOp = Expression();
} }
} }
...@@ -1617,7 +1619,7 @@ void FormulaCompiler::Factor() ...@@ -1617,7 +1619,7 @@ void FormulaCompiler::Factor()
} }
else else
SetError( FormulaError::PairExpected); SetError( FormulaError::PairExpected);
sal_uInt8 nSepCount = 0; sal_uInt32 nSepCount = 0;
if( !bNoParam ) if( !bNoParam )
{ {
nSepCount++; nSepCount++;
...@@ -1626,6 +1628,8 @@ void FormulaCompiler::Factor() ...@@ -1626,6 +1628,8 @@ void FormulaCompiler::Factor()
NextToken(); NextToken();
CheckSetForceArrayParameter( mpToken, nSepCount); CheckSetForceArrayParameter( mpToken, nSepCount);
nSepCount++; nSepCount++;
if (nSepCount > FORMULA_MAXPARAMS)
SetError( FormulaError::CodeOverflow);
eOp = Expression(); eOp = Expression();
} }
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#define FORMULA_MAXJUMPCOUNT 32 /* maximum number of jumps (ocChoose) */ #define FORMULA_MAXJUMPCOUNT 32 /* maximum number of jumps (ocChoose) */
#define FORMULA_MAXTOKENS 8192 /* maximum number of tokens in formula */ #define FORMULA_MAXTOKENS 8192 /* maximum number of tokens in formula */
#define FORMULA_MAXPARAMS 255 /* maximum number of parameters per function (byte) */
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment