summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-23 16:49:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-24 07:55:10 +0100
commitda67b0be49795ec09a2794dd0fb3e5b29f066dc3 (patch)
tree34ebde20934773bd32a382742211bcabde512f6e
parentff166845fa5ed178a97b54bb2deef4beb0cf3bdf (diff)
Remove presumably dead nLen < USHRT_MAX check
The original code of 7b0b5cdfeed656b279bc32cd929630d5fc25878b "initial import" read + long nLen = ( (nNextPieceCp < nBehindTextCp) + ? nNextPieceCp + : nBehindTextCp + ) + - nAktStartCp; + + if( 0 >= nLen ) break; + + if( nLen > USHRT_MAX - 1 ) + nLen = USHRT_MAX - 1; + + if( bIsUnicode ) + rStr.Append( WW8Read_xstz( rStrm, (USHORT)nLen, FALSE ) ); + else + { + ByteString aByteStr; // Alloc methode automatically sets Zero at the end + sal_Char* pByteData = aByteStr.AllocBuffer( nLen ); + + sal_Size nWasRead = rStrm.Read( pByteData, nLen ); + if( nWasRead != nLen ) + aByteStr.ReleaseBufferAccess( nWasRead ); + + rStr += String( aByteStr, eEnc ); + } + nTotalRead += nLen; + nAktStartCp += nLen; + if( nTotalRead != rStr.Len() ) break; casting nLen to USHORT in the call to WW8Read_xstz, while the current code looks like it should work fine for larger nLen. Change-Id: Ie3a0d654ef45421cbbe8e823259e8dfd27bd27e2 Reviewed-on: https://gerrit.libreoffice.org/48437 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx3
1 files changed, 0 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index dd8d2479233a..5cbaefdfd6fd 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -2050,9 +2050,6 @@ sal_Int32 WW8ScannerBase::WW8ReadString( SvStream& rStrm, OUString& rStr,
if (bFail)
break;
- if( nLen > USHRT_MAX - 1 )
- nLen = USHRT_MAX - 1;
-
if( 0 >= nLen )
break;