]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611) (#140728)
authorCody Maloney <cmaloney@users.noreply.github.com>
Wed, 29 Oct 2025 12:31:48 +0000 (05:31 -0700)
committerGitHub <noreply@github.com>
Wed, 29 Oct 2025 12:31:48 +0000 (13:31 +0100)
commit9a7dccd7a179c82ed50717e7d855e0be558c7c91
treedb73fe3b88f26566a2a1182a52d9d97e29df666c
parent7c4a8e58188d63f9f83ca888dd33e6973b915351
[3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-140611) (#140728)

* [3.14] gh-140607: Validate returned byte count in RawIOBase.read (GH-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.
(cherry picked from commit 0f0a362768aecb4c791724cce486d8317533a94d)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
* fixup: Use older attribute name

---------

Co-authored-by: Shamil <ashm.tech@proton.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/_pyio.py
Lib/test/test_io.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