Kaydet (Commit) 5c3f673c authored tarafından Mark Wielaard's avatar Mark Wielaard Kaydeden (comit) Caolán McNamara

Robustify WW8FormulaControl::FormulaRead reading SvStream.

The >>operator of SvStream doesn't initialize a variable if the stream
is faulty. So initialize the variables before usage to prevent reading
wrong/random bits.

Change-Id: Ia66dd6d8574c36e7229a58347f2e2c1e0fe2e248
Reviewed-on: https://gerrit.libreoffice.org/4636Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 92ffe57f
...@@ -2176,7 +2176,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich, ...@@ -2176,7 +2176,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
{ {
sal_uInt8 nField; sal_uInt8 nField;
// nHeaderBype == version // nHeaderBype == version
sal_uInt32 nHeaderByte; sal_uInt32 nHeaderByte = 0;
// The following is a FFData structure as described in // The following is a FFData structure as described in
// Microsoft's DOC specification (chapter 2.9.78) // Microsoft's DOC specification (chapter 2.9.78)
...@@ -2185,9 +2185,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich, ...@@ -2185,9 +2185,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
// might be better to read the bits as a 16 bit word // might be better to read the bits as a 16 bit word
// ( like it is in the spec. ) // ( like it is in the spec. )
sal_uInt8 bits1; sal_uInt8 bits1 = 0;
*pDataStream >> bits1; *pDataStream >> bits1;
sal_uInt8 bits2; sal_uInt8 bits2 = 0;
*pDataStream >> bits2; *pDataStream >> bits2;
sal_uInt8 iType = ( bits1 & 0x3 ); sal_uInt8 iType = ( bits1 & 0x3 );
...@@ -2199,10 +2199,10 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich, ...@@ -2199,10 +2199,10 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
sal_uInt8 iRes = (bits1 & 0x7C) >> 2; sal_uInt8 iRes = (bits1 & 0x7C) >> 2;
sal_uInt16 cch; sal_uInt16 cch = 0;
*pDataStream >> cch; *pDataStream >> cch;
sal_uInt16 hps; sal_uInt16 hps = 0;
*pDataStream >> hps; *pDataStream >> hps;
// xstzName // xstzName
...@@ -2241,9 +2241,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich, ...@@ -2241,9 +2241,9 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
{ {
bool bAllOk = true; bool bAllOk = true;
// SSTB (see Spec. 2.2.4) // SSTB (see Spec. 2.2.4)
sal_uInt16 fExtend; sal_uInt16 fExtend = 0;
*pDataStream >> fExtend; *pDataStream >> fExtend;
sal_uInt16 nNoStrings; sal_uInt16 nNoStrings = 0;
// Isn't it that if fExtend isn't 0xFFFF then fExtend actually // Isn't it that if fExtend isn't 0xFFFF then fExtend actually
// doesn't exist and we really have just read nNoStrings ( or cData )? // doesn't exist and we really have just read nNoStrings ( or cData )?
...@@ -2252,7 +2252,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich, ...@@ -2252,7 +2252,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
*pDataStream >> nNoStrings; *pDataStream >> nNoStrings;
// I guess this should be zero ( and we should ensure that ) // I guess this should be zero ( and we should ensure that )
sal_uInt16 cbExtra; sal_uInt16 cbExtra = 0;
*pDataStream >> cbExtra; *pDataStream >> cbExtra;
OSL_ENSURE(bAllOk, OSL_ENSURE(bAllOk,
......
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