Kaydet (Commit) 78bcc5dd authored tarafından Eike Rathke's avatar Eike Rathke

ofz#4123 do not read past end of file

Change-Id: I1fa3543d541ea084a43a1a11f62680fa798f5647
üst 1aba1955
...@@ -143,31 +143,51 @@ inline void LotusConverterBase::Ignore( const long nSeekRel ) ...@@ -143,31 +143,51 @@ inline void LotusConverterBase::Ignore( const long nSeekRel )
inline void LotusConverterBase::Read( sal_uInt8& nByte ) inline void LotusConverterBase::Read( sal_uInt8& nByte )
{ {
aIn.ReadUChar( nByte ); aIn.ReadUChar( nByte );
if (aIn.good())
nBytesLeft--; nBytesLeft--;
else
{
// SvStream::ReadUChar() does not init a single char on failure. This
// behaviour is even tested in a unit test.
nByte = 0;
nBytesLeft = -1; // bail out early
}
} }
inline void LotusConverterBase::Read( sal_uInt16& nUINT16 ) inline void LotusConverterBase::Read( sal_uInt16& nUINT16 )
{ {
aIn.ReadUInt16( nUINT16 ); aIn.ReadUInt16( nUINT16 );
if (aIn.good())
nBytesLeft -= 2; nBytesLeft -= 2;
else
nBytesLeft = -1; // bail out early
} }
inline void LotusConverterBase::Read( sal_Int16& nINT16 ) inline void LotusConverterBase::Read( sal_Int16& nINT16 )
{ {
aIn.ReadInt16( nINT16 ); aIn.ReadInt16( nINT16 );
if (aIn.good())
nBytesLeft -= 2; nBytesLeft -= 2;
else
nBytesLeft = -1; // bail out early
} }
inline void LotusConverterBase::Read( double& fDouble ) inline void LotusConverterBase::Read( double& fDouble )
{ {
aIn.ReadDouble( fDouble ); aIn.ReadDouble( fDouble );
if (aIn.good())
nBytesLeft -= 8; nBytesLeft -= 8;
else
nBytesLeft = -1; // bail out early
} }
inline void LotusConverterBase::Read( sal_uInt32& nUINT32 ) inline void LotusConverterBase::Read( sal_uInt32& nUINT32 )
{ {
aIn.ReadUInt32( nUINT32 ); aIn.ReadUInt32( nUINT32 );
if (aIn.good())
nBytesLeft -= 4; nBytesLeft -= 4;
else
nBytesLeft = -1; // bail out early
} }
#endif #endif
......
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