New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcelReaderFactory.CreateBinaryReader throws OutOfMemoryException #382

Metalnem opened this Issue Dec 25, 2018 · 3 comments


None yet
3 participants
Copy link

Metalnem commented Dec 25, 2018

ExcelReaderFactory.CreateBinaryReader throws OutOfMemoryException after trying to open a 26KB invalid Excel file for more than 25s. The file can be found in the attached archive. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):


using (var file = File.OpenRead(path))

Found via SharpFuzz.


This comment has been minimized.

Copy link

wizardgsz commented Dec 28, 2018

"Next sector cannot be 0. Possibly corrupt excel file" the error message


This comment has been minimized.

Copy link

Metalnem commented Dec 28, 2018

The stack trace that I'm getting on macOS running .NET Core 2.1 looks like this:

An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Private.CoreLib.dll
   at System.Collections.Generic.List`1.set_Capacity(Int32 value)
   at System.Collections.Generic.List`1.AddWithResize(T item)
   at ExcelDataReader.Core.CompoundFormat.CompoundDocument.GetSectorChain(UInt32 sector, List`1 sectorTable)
   at ExcelDataReader.Core.CompoundFormat.CompoundDocument..ctor(Stream stream)
   at ExcelDataReader.ExcelReaderFactory.CreateBinaryReader(Stream fileStream, ExcelReaderConfiguration configuration)
   at ExcelDataReader.Run.Program.Main(String[] args) in

This comment has been minimized.

Copy link

andersnm commented Dec 28, 2018

@Metalnem Thanks for the report and repro! There is a problem where cyclic sector chains in the Compound Document parser are not handled.

@wizardgsz Looks like you are testing with ExcelDataReader 2.x? This case was handled before, but was removed around 3.0 - likely due to lack of test data. Although the original code looks to only handle certain kinds of circular chains: 4605ce8#diff-b7be87d681fb2b3432dc0dcca0c20840L80

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