-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Issue #60416 - Correction of BufferedReadStream 's Position #60529
Conversation
Correction of BufferedReadStream's Position property setter.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting this issue and following through with the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Even though this is a bug fix, I don't think this meets the bar for patching given that it's unusual to seek a BufferedReadStream
and it's rare for the inner stream to even be seekable which is probably why this took so long to discover.
Correction of Microsoft.AspNetCore.WebUtilities.BufferedReadStream Position property
The implementation of Position's property setter for Microsoft.AspNetCore.WebUtilities.BufferedReadStream class was incorrect and changed accordingly with the proposed solution described in the issue #60416 .
Description
By trying to use Microsoft.AspNetCore.WebUtilities.MultipartReader in a way that is directly using the section streams outside the initial reading loop (made through ReadNextSectionAsync), I've come to at least one case (when dealing with more than two section streams) where the conclusion is that the Position property of BufferedReadStream has an incorrect implementation when trying to position inside the internal buffer.
The solution was to advance in the internal buffer not with the offset between old position and new position (i.e. backward innerOffset), but until that offset / distance, so in the end the new Position will reflect the desired input value when getting the property.
Fixes #60416