-
Notifications
You must be signed in to change notification settings - Fork 78
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
Reading from StreamDecorator with oversized buffer fails #88
Comments
aunverdorben-dap
added a commit
to DAP-GmbH/openmcdf
that referenced
this issue
May 25, 2022
aunverdorben-dap
added a commit
to DAP-GmbH/openmcdf
that referenced
this issue
May 25, 2022
aunverdorben-dap
added a commit
to DAP-GmbH/openmcdf
that referenced
this issue
Aug 30, 2022
aunverdorben-dap
added a commit
to DAP-GmbH/openmcdf
that referenced
this issue
Aug 30, 2022
ironfede
added a commit
that referenced
this issue
Aug 30, 2022
Added unit test method to demonstrate issue #88 and provided a fix.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assume you have a CFStream with a length of 670 bytes. When accessing the data from the CFStream via StreamDecorator and reading from it into an oversized buffer like so
a System.ArgumentOutOfRangeException will occur.
Now, one could argue the buffer size should not exceed the length of the stream but when using .NET funcionality like Stream.CopyTo or wrapping a CompressedStream around the StreamDecorator the exception will also occur, because Stream.CopyTo and DeflateStream both work with their default buffer sizes a) for performance/IO throughput reasons and b) because they need to be able to work with non-seekable streams and even with streams with unknown length.
The Stream.Read documentation states:
So it's perfectly ok to request 81920 (see example code above) but only get 670 bytes of data when there's simply not more data available.
The text was updated successfully, but these errors were encountered: