]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-140607: Validate returned byte count in RawIOBase.read (#140611)
authorCody Maloney <cmaloney@users.noreply.github.com>
Mon, 27 Oct 2025 18:06:46 +0000 (11:06 -0700)
committerGitHub <noreply@github.com>
Mon, 27 Oct 2025 18:06:46 +0000 (18:06 +0000)
commit0f0a362768aecb4c791724cce486d8317533a94d
tree6fe98628056dabc92980b58fdd9b6a10bae5b843
parent313145eab5f6ebca21d2e3c80c130980d3bcdc88
gh-140607: Validate returned byte count in RawIOBase.read (#140611)

While `RawIOBase.readinto` should return a count of bytes between 0 and
the length of the given buffer, it is not required to. Add validation
inside RawIOBase.read() that the returned byte count is valid.

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/_pyio.py
Lib/test/test_io/test_general.py
Misc/NEWS.d/next/Library/2025-10-25-21-04-00.gh-issue-140607.oOZGxS.rst [new file with mode: 0644]
Modules/_io/iobase.c