Describe the bug
With a writable stream and an invalid FAT, RootStorage.Dispose can loop for an uncomfortably long time.
This was found by a fuzzer (FatChainLoopInDispose.zip).
Note that attempting to open the attached file with OpenMcdf.Explorer will fail, since it tries to open all streams and detects the FAT corruption.
To Reproduce
[TestMethod]
[Timeout(3000, CooperativeCancellation = false)]
[DataRow("FatChainLoopInDispose")]
public void FatChainLoopInDispose(string fileName)
{
var bytes = File.ReadAllBytes(fileName);
using var stream = new MemoryStream(bytes);
using var rootStorage = RootStorage.Open(stream, StorageModeFlags.LeaveOpen);
Assert.ThrowsExactly<FileNotFoundException>(() => rootStorage.OpenStream("Metadata"));
}
This test will time out, but it will succeed with a read-only stream (e.g. new MemoryStream(bytes, false) or a FileStream with FileAccess.Read).
Expected behavior
Not to hang.
Actual behavior
Several minutes hang.
Environment (please complete the following information):
- Version 3.3.0
- OS: Windows 11 23H2
- TFM: net10.0
Reactions are currently unavailable
Describe the bug
With a writable stream and an invalid FAT, RootStorage.Dispose can loop for an uncomfortably long time.
This was found by a fuzzer (FatChainLoopInDispose.zip).
Note that attempting to open the attached file with OpenMcdf.Explorer will fail, since it tries to open all streams and detects the FAT corruption.
To Reproduce
This test will time out, but it will succeed with a read-only stream (e.g. new MemoryStream(bytes, false) or a FileStream with FileAccess.Read).
Expected behavior
Not to hang.
Actual behavior
Several minutes hang.
Environment (please complete the following information):