ofz: more check bounds on read
Change-Id: I92b10aeab34cb6a78deff1d4b54545c8f506113c
This commit is contained in:
@@ -99,7 +99,7 @@ sal_uInt32 CGM::GetBackGroundColor()
|
|||||||
sal_uInt32 CGM::ImplGetUI16( sal_uInt32 /*nAlign*/ )
|
sal_uInt32 CGM::ImplGetUI16( sal_uInt32 /*nAlign*/ )
|
||||||
{
|
{
|
||||||
sal_uInt8* pSource = mpSource + mnParaSize;
|
sal_uInt8* pSource = mpSource + mnParaSize;
|
||||||
if (pSource + 2 > mpEndValidSource)
|
if (mpEndValidSource - pSource < 2)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
mnParaSize += 2;
|
mnParaSize += 2;
|
||||||
return ( pSource[ 0 ] << 8 ) + pSource[ 1 ];
|
return ( pSource[ 0 ] << 8 ) + pSource[ 1 ];
|
||||||
@@ -113,7 +113,7 @@ sal_uInt8 CGM::ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision )
|
|||||||
sal_Int32 CGM::ImplGetI( sal_uInt32 nPrecision )
|
sal_Int32 CGM::ImplGetI( sal_uInt32 nPrecision )
|
||||||
{
|
{
|
||||||
sal_uInt8* pSource = mpSource + mnParaSize;
|
sal_uInt8* pSource = mpSource + mnParaSize;
|
||||||
if (pSource + nPrecision > mpEndValidSource)
|
if (mpEndValidSource - pSource < nPrecision)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
mnParaSize += nPrecision;
|
mnParaSize += nPrecision;
|
||||||
switch( nPrecision )
|
switch( nPrecision )
|
||||||
@@ -145,7 +145,7 @@ sal_Int32 CGM::ImplGetI( sal_uInt32 nPrecision )
|
|||||||
sal_uInt32 CGM::ImplGetUI( sal_uInt32 nPrecision )
|
sal_uInt32 CGM::ImplGetUI( sal_uInt32 nPrecision )
|
||||||
{
|
{
|
||||||
sal_uInt8* pSource = mpSource + mnParaSize;
|
sal_uInt8* pSource = mpSource + mnParaSize;
|
||||||
if (pSource + nPrecision > mpEndValidSource)
|
if (mpEndValidSource - pSource < nPrecision)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
mnParaSize += nPrecision;
|
mnParaSize += nPrecision;
|
||||||
switch( nPrecision )
|
switch( nPrecision )
|
||||||
@@ -200,7 +200,7 @@ double CGM::ImplGetFloat( RealPrecision eRealPrecision, sal_uInt32 nRealSize )
|
|||||||
const bool bCompatible = false;
|
const bool bCompatible = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mpSource + mnParaSize + nRealSize > mpEndValidSource)
|
if (mpEndValidSource - (mpSource + mnParaSize) < nRealSize)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
|
|
||||||
if ( bCompatible )
|
if ( bCompatible )
|
||||||
|
@@ -176,8 +176,11 @@ void CGM::ImplDoClass1()
|
|||||||
{
|
{
|
||||||
while ( mnParaSize < mnElementSize )
|
while ( mnParaSize < mnElementSize )
|
||||||
{
|
{
|
||||||
sal_uInt32 nSize;
|
sal_uInt32 nSize = ImplGetUI(1);
|
||||||
nSize = ImplGetUI( 1 );
|
|
||||||
|
if (mpEndValidSource - (mpSource + mnParaSize) < nSize)
|
||||||
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
|
|
||||||
pElement->aFontList.InsertName( mpSource + mnParaSize, nSize );
|
pElement->aFontList.InsertName( mpSource + mnParaSize, nSize );
|
||||||
mnParaSize += nSize;
|
mnParaSize += nSize;
|
||||||
}
|
}
|
||||||
@@ -187,10 +190,8 @@ void CGM::ImplDoClass1()
|
|||||||
{
|
{
|
||||||
while ( mnParaSize < mnElementSize )
|
while ( mnParaSize < mnElementSize )
|
||||||
{
|
{
|
||||||
sal_uInt32 nCharSetType;
|
sal_uInt32 nCharSetType = ImplGetUI16();
|
||||||
sal_uInt32 nSize;
|
sal_uInt32 nSize = ImplGetUI(1);
|
||||||
nCharSetType = ImplGetUI16();
|
|
||||||
nSize = ImplGetUI( 1 );
|
|
||||||
pElement->aFontList.InsertCharSet( (CharSetType)nCharSetType, mpSource + mnParaSize, nSize );
|
pElement->aFontList.InsertCharSet( (CharSetType)nCharSetType, mpSource + mnParaSize, nSize );
|
||||||
mnParaSize += nSize;
|
mnParaSize += nSize;
|
||||||
}
|
}
|
||||||
|
@@ -186,7 +186,7 @@ void CGM::ImplDoClass4()
|
|||||||
sal_uInt32 nType = ImplGetUI16( 4 );
|
sal_uInt32 nType = ImplGetUI16( 4 );
|
||||||
sal_uInt32 nSize = ImplGetUI( 1 );
|
sal_uInt32 nSize = ImplGetUI( 1 );
|
||||||
|
|
||||||
if (mpSource + mnParaSize + nSize > mpEndValidSource)
|
if (mpEndValidSource - (mpSource + mnParaSize) < nSize)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
|
|
||||||
mpSource[mnParaSize + nSize] = 0;
|
mpSource[mnParaSize + nSize] = 0;
|
||||||
@@ -224,7 +224,7 @@ void CGM::ImplDoClass4()
|
|||||||
sal_uInt32 nType = ImplGetUI16(4);
|
sal_uInt32 nType = ImplGetUI16(4);
|
||||||
sal_uInt32 nSize = ImplGetUI(1);
|
sal_uInt32 nSize = ImplGetUI(1);
|
||||||
|
|
||||||
if (mpSource + mnParaSize + nSize > mpEndValidSource)
|
if (mpEndValidSource - (mpSource + mnParaSize) < nSize)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
|
|
||||||
mpSource[ mnParaSize + nSize ] = 0;
|
mpSource[ mnParaSize + nSize ] = 0;
|
||||||
@@ -242,7 +242,7 @@ void CGM::ImplDoClass4()
|
|||||||
sal_uInt32 nType = ImplGetUI16( 4 );
|
sal_uInt32 nType = ImplGetUI16( 4 );
|
||||||
sal_uInt32 nSize = ImplGetUI( 1 );
|
sal_uInt32 nSize = ImplGetUI( 1 );
|
||||||
|
|
||||||
if (mpSource + mnParaSize + nSize > mpEndValidSource)
|
if (mpEndValidSource - (mpSource + mnParaSize) < nSize)
|
||||||
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
throw css::uno::Exception("attempt to read past end of input", nullptr);
|
||||||
|
|
||||||
mpSource[ mnParaSize + nSize ] = 0;
|
mpSource[ mnParaSize + nSize ] = 0;
|
||||||
|
Reference in New Issue
Block a user