Repository navigation
Fix SpooledTemporaryFile.readinto/readinto1 reading twice before rollover - #1215
Merged
Merged
Conversation
…over Signed-off-by: c-tonneslan <cst0520@gmail.com>
Signed-off-by: c-tonneslan <cst0520@gmail.com>
tapetersen
approved these changes
Jul 10, 2026
tapetersen
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for a good PR.
Co-authored-by: Tobias Alex-Petersen <tobias.alex.petersen@gmail.com>
for more information, see https://pre-commit.ci
Owner
|
I was contacted by Rohit Sriram, a security researcher who ran Faultmark against AnyIO's code. This was the only issue the software found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Before rollover,
SpooledTemporaryFile.readintoandreadinto1read from the underlying file object but discard the result and fall through tosuper().readinto(b), which reads a second time. The buffer is overwritten by the second read and the file position advances twice, so the caller silently loses the first chunk of data.readinto1additionally calledself._fp.readintoinstead ofself._fp.readinto1.Every other read method on the class (
read,read1,readline,readlines) alreadyreturnfrom the non-rolled branch; these two were missing thereturn.Only triggers before rollover (while the spooled data is still in memory), which is why it went unnoticed.
Checklist
tests/) which would fail without your patchdocs/), in case of behavior changes or new featuresdocs/versionhistory.rst).