ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
302 stars 73 forks source link

Exception when reading the properties from a Word document that contains multiple users defined properties #34

Closed Numpsy closed 5 years ago

Numpsy commented 5 years ago

Hi,

Using the latest version of the source as of now, if i open the DocumentSummaryInformation stream on a word document that contains multiple user defined properties and try to call AsOLEPropertiesContainer on it, I get a variety of exceptions thrown with a call stack like

at System.IO.BinaryReader.ReadBytes(Int32 count)
   at OpenMcdf.Extensions.OLEProperties.DictionaryEntry.Read(BinaryReader br)
   at OpenMcdf.Extensions.OLEProperties.DictionaryProperty.Read(BinaryReader br)
   at OpenMcdf.Extensions.OLEProperties.PropertySetStream.ReadProperty(UInt32 propertyIdentifier, Int32 codePage, BinaryReader br)
   at OpenMcdf.Extensions.OLEProperties.PropertySetStream.Read(BinaryReader br)
   at OpenMcdf.Extensions.OLEProperties.OLEPropertiesContainer..ctor(CFStream cfStream)
   at OpenMcdf.Extensions.OlePropertiesExtensions.AsOLEPropertiesContainer(CFStream cfStream)

A quick attempt at debugging suggests that the call to DictionaryEntry.Read for the second entry is trying to set its length to a huge positive of negative number and then failing its attempt to read that amount of data.

see attached zip for an example that fails.

Thanks. 2custom.zip

ironfede commented 5 years ago

Many many thanks @Numpsy for your precise report. I'm going to work on it as soon as possible.