Kaydet (Commit) 4fb14703 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#4068 Integer-overflow

Change-Id: Id61f4f82b66e7efa4d3ef062d2756acddcee43b8
Reviewed-on: https://gerrit.libreoffice.org/44327Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b97d210b
...@@ -1481,6 +1481,8 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode, ...@@ -1481,6 +1481,8 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode,
else else
*pIsUnicode = m_pWw8Fib->m_fExtChar; *pIsUnicode = m_pWw8Fib->m_fExtChar;
WW8_FC nRet;
if( m_pPieceIter ) if( m_pPieceIter )
{ {
// Complex File // Complex File
...@@ -1510,7 +1512,7 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode, ...@@ -1510,7 +1512,7 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode,
if( pNextPieceCp ) if( pNextPieceCp )
*pNextPieceCp = nCpEnd; *pNextPieceCp = nCpEnd;
WW8_FC nRet = SVBT32ToUInt32( static_cast<WW8_PCD*>(pData)->fc ); nRet = SVBT32ToUInt32( static_cast<WW8_PCD*>(pData)->fc );
if (m_pWw8Fib->m_nVersion >= 8) if (m_pWw8Fib->m_nVersion >= 8)
nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode ); nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode );
else else
...@@ -1555,7 +1557,13 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode, ...@@ -1555,7 +1557,13 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode,
} }
// No complex file // No complex file
return m_pWw8Fib->m_fcMin + nCpPos; const bool bFail = o3tl::checked_add(m_pWw8Fib->m_fcMin, nCpPos, nRet);
if (bFail)
{
SAL_WARN("sw.ww8", "broken offset, ignoring");
return WW8_CP_MAX;
}
return nRet;
} }
// class WW8ScannerBase // class WW8ScannerBase
......
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