Description
When I run this code with OpenMCDF 2.4.0 it will crash when writing the 9th stream.
{
string tempFile = @"d:\OpenMCDFCrash.dat";
// create big MCDF file
CFSVersion version = CFSVersion.Ver_3;
CFSConfiguration configuration = CFSConfiguration.Default;
CFSUpdateMode updateMode = CFSUpdateMode.Update;
using (CompoundFile compoundFile = new CompoundFile(version, configuration))
{
compoundFile.SaveAs(tempFile);
compoundFile.Close();
}
using (var compoundFile = new CompoundFile(tempFile, updateMode, configuration))
{
byte[] data = new byte[6617123];
for (int i = 0; i < 100; i++)
{
var cfStream = compoundFile.RootStorage.AddStream($"Stream {i}.dat");
cfStream.SetData(data);
}
compoundFile.Commit();
}
}
I get:
System.IO.IOException: Seek before origin
at OpenMcdf.StreamView.Seek(Int64 offset, SeekOrigin origin)
at OpenMcdf.StreamRW.Seek(Int64 count, SeekOrigin origin)
at OpenMcdf.CompoundFile.AllocateDIFATSectorChain(List1 FATsectorChain) at OpenMcdf.CompoundFile.AllocateFATSectorChain(List
1 sectorChain)
at OpenMcdf.CompoundFile.AllocateSectorChain(List1 sectorChain) at OpenMcdf.CompoundFile.SetSectorChain(List
1 sectorChain)
at OpenMcdf.CompoundFile.SetStreamLength(CFItem cfItem, Int64 length)
at OpenMcdf.CompoundFile.WriteData(CFItem cfItem, Byte[] buffer, Int64 position, Int32 offset, Int32 count)
at OpenMcdf.CompoundFile.WriteData(CFItem cfItem, Int64 position, Byte[] buffer)
at OpenMcdf.CompoundFile.WriteData(CFItem cfItem, Byte[] buffer)
at OpenMcdf.CFStream.SetData(Byte[] data)
at OpenMCDF2._4._0CrashRepro.Program.Main(String[] args) in