Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Created Issue: Arbitrary buffer size is too small; crash on save [14811]

$
0
0
I have a file generated with Excel 2010 (too large to attach) that, upon loading then saving with EPPlus without any changes, results in a "Index out of range" exception and the file is not saved.

CompoundDocument::GetChunk() is responsible for the error. It uses a buffer of size 4098 to hold a copy of the chunked data to return to the caller. __There are no checks to ensure the buffer is large enough to hold all the tokens being copied!__ The chosen hard-coded size is insufficient for my file, as the code attempts to index beyond byte 4098. For my particular file, a buffer size of at least 4109 is required to avoid this crash, but this is not necessarily the limit.

To fix this specific problem, change line 240 of CompoundDocument.cs from:

```
byte[] buffer = new byte[4098];
```
to:

```
byte[] buffer = new byte[4109];
```

Ideally, the buffer size allocated would be determined by counting the required bytes in the source data.



Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>