ironfede / openmcdf

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

Should we reject invalid miniSectorShift, sectorShift, miniStreamCutoffSize and byteOrder values? #73

Closed hughbe closed 1 year ago

hughbe commented 3 years ago

From [MS-CFB]:

Mini Sector Shift (2 bytes): This field MUST be set to 0x0006. This field specifies the sector size of the Mini Stream as a power of 2. The sector size of the Mini Stream MUST be 64 bytes

Sector Shift (2 bytes): This field MUST be set to 0x0009, or 0x000c, depending on the Major Version field. This field specifies the sector size of the compound file as a power of 2 If Major Version is 3, the Sector Shift MUST be 0x0009, specifying a sector size of 512 bytes. If Major Version is 4, the Sector Shift MUST be 0x000C, specifying a sector size of 4096 bytes

Mini Stream Cutoff Size (4 bytes): This integer field MUST be set to 0x00001000. This field specifies the maximum size of a user-defined data stream that is allocated from the mini FAT and mini stream, and that cutoff is 4,096 bytes. Any user-defined data stream that is greater than or equal to this cutoff size must be allocated as normal sectors from the FAT

Byte Order (2 bytes): This field MUST be set to 0xFFFE. This field is a byte order mark for all integer field specifying little-endian byte order.

I don't think we validate this in this library

ironfede commented 1 year ago

Validation added Thx @hughbe

Best Regards Federico