summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-08-06 20:55:32 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-08-07 11:24:23 +0200
commit1faac635fd37dd04f78c9b420ffefd289969c90d (patch)
treee3c17505d42198d9a380a5538c4928efcf625865 /svtools
parentdaa589af6a7c8ad6bdb273fda949553ad508bd9e (diff)
ofz#57384 Timeout
Change-Id: Ic2007f52056acd46f96d454c1fdb7b8ca8838d70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155386 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/svrtf/svparser.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 1a8e73d0edb6..c003bcae21a9 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -78,6 +78,7 @@ SvParser<T>::SvParser( SvStream& rIn, sal_uInt8 nStackSize )
: rInput( rIn )
, nlLineNr( 1 )
, nlLinePos( 1 )
+ , nConversionErrors( 0 )
, pImplData( nullptr )
, m_nTokenIndex(0)
, nTokenValue( 0 )
@@ -338,6 +339,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
// do
c = '?';
nChars = 1;
+ ++nConversionErrors;
}
}
}
@@ -384,6 +386,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
c = reinterpret_cast<unsigned char&>( sBuffer[0] );
rInput.SeekRel( -(nLen-1) );
nChars = 1;
+ ++nConversionErrors;
}
}
}
@@ -405,7 +408,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
// because a conversion is not available, do no conversion at all.
c = reinterpret_cast<unsigned char&>( c1 );
nChars = 1;
-
+ ++nConversionErrors;
}
}
}
@@ -416,6 +419,12 @@ sal_uInt32 SvParser<T>::GetNextChar()
if ( ! rtl::isUnicodeScalarValue( c ) )
c = '?' ;
+ if (bFuzzing && nConversionErrors > 128)
+ {
+ SAL_WARN("svtools", "SvParser::GetNextChar too many conversion errors while fuzzing, abandoning for performance");
+ bErr = true;
+ }
+
if( bErr )
{
if( ERRCODE_IO_PENDING == rInput.GetError() )