summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-08 09:58:31 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-01-09 10:04:24 +0100
commit71da7445e50eadfce261fcd2f82d16cbaa017041 (patch)
tree7240176a0d8cc3a6c0af65e1aeed5647b63717f9 /tools
parent088df374f01a28c06c4602f33fea2b717bf403f5 (diff)
ofz#5000 Integer-overflow
Change-Id: I74871848ddddafd1a89ddb3eee4a307cc5d7c16b Reviewed-on: https://gerrit.libreoffice.org/47573 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/bigint.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index cda2be1843d7..6fa9a2c472f0 100644
--- a/tools/source/generic/bigint.cxx
+++ b/tools/source/generic/bigint.cxx
@@ -330,21 +330,21 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const
for (j = aTmpA.nLen - 1; j >= nLenB; j--)
{ // guess divisor
- sal_Int32 nTmp = ( (sal_Int32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
+ sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1])
nQ = 0xFFFF;
else
- nQ = (sal_uInt16)(((sal_uInt32)nTmp) / aTmpB.nNum[nLenB1]);
+ nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]);
if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) >
- ((((sal_uInt32)nTmp) - (sal_uInt32)aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2])
+ ((nTmp - (sal_uInt32)aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2])
nQ--;
// Start division
nK = 0;
for (i = 0; i < nLenB; i++)
{
- nTmp = (sal_Int32)aTmpA.nNum[j - nLenB + i]
- - ((sal_Int32)aTmpB.nNum[i] * nQ)
+ nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i]
+ - ((sal_uInt32)aTmpB.nNum[i] * nQ)
- nK;
aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp;
nK = (sal_uInt16) (nTmp >> 16);
@@ -397,21 +397,21 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const
for (j = aTmpA.nLen - 1; j >= nLenB; j--)
{ // Guess divisor
- sal_Int32 nTmp = ( (sal_Int32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
+ sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1];
if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1])
nQ = 0xFFFF;
else
- nQ = (sal_uInt16)(((sal_uInt32)nTmp) / aTmpB.nNum[nLenB1]);
+ nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]);
if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) >
- ((((sal_uInt32)nTmp) - aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2])
+ ((nTmp - aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2])
nQ--;
// Start division
nK = 0;
for (i = 0; i < nLenB; i++)
{
- nTmp = (sal_Int32)aTmpA.nNum[j - nLenB + i]
- - ((sal_Int32)aTmpB.nNum[i] * nQ)
+ nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i]
+ - ((sal_uInt32)aTmpB.nNum[i] * nQ)
- nK;
aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp;
nK = (sal_uInt16) (nTmp >> 16);