FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`RootContext.TrimBaseStream` does not validate FAT, resulting in ~INT_MAX iterations in `RootStorage.Dispose` (blocks several minutes) · Issue #485 · openmcdf/openmcdf · GitHub

RootContext.TrimBaseStream does not validate FAT, resulting in ~INT_MAX iterations in RootStorage.Dispose (blocks several minutes) #485

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL