Open ericstj opened 4 months ago
Tagging subscribers to this area: @dotnet/area-system-formats-tar See info in area-owners.md if you want to be subscribed.
This code determines how much of the superstream was read through the SubReadStream
by calling the Position
property. That getter throws ODE because the SubReadStream
got disposed:
Description
When disposing the stream of a single
TarEntry
, I cannot advance theTarReader
to the next entry.Consider the following sample:
This will throw
The suspect code is here: https://github.com/dotnet/runtime/blob/84b33395057737db3ea342a5151feb6b90c1b6f6/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs#L200-L237
Reproduction Steps
See above
Expected behavior
No exception thrown
Actual behavior
ObjectDisposedException
Regression?
No
Known Workarounds
Copy the entry to a memory stream. Copy the archive to a memory stream before opening (so it is seek-able). Etc
Configuration
No response
Other information
I noticed when debugging this that the state of the
SubReadStream
was the following:Note that
_positionInSuperStream
is the same as_endInSuperStream
. I noticed that theHasReachedEnd
property is checked before accessingPosition
which will throw. It seems likeHasReachedEnd
checks both the fields mentioned, but will only treat it as true if greater, perhaps it should have been greater or equal?