ironfede / openmcdf

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

Fix validation logic in GetDifatSectorChain #43

Closed christianscheuer closed 1 year ago

christianscheuer commented 5 years ago

This fixes #42

I was able to step through and (partially) understand what was going on. It seems like sometimes a sector will be terminated with 0's instead of FREESECT or ENDOFCHAIN.

However this was only part of the solution. By allowing the NoValidationException to also not throw the CFCorruptedFileException on sectors having been traversed more than once, I'm now able to open these files again.

ironfede commented 1 year ago

TSorry for the delayed response and Thank you @christianscheuer , your finding is absolutely meaningful but allowing a chain termination with a non-normative value could open the door to subtle bugs in the long run so I would prefer, in a balance between strict check and not-nomative files, the first one in this particular case since 0 is a value that falls in the domain of valid sector ids even if with a low likelihood. As I remarked in our conversation on #42 , I would need a specific use case .aff file to implement a more "generic" solution that can possibly avoid to introduce problems for the standard cases ( I understand anyway that's difficult to provide a non-sensitive specific file to test). Thank You

Best Regards, Federico