Staging
v0.5.1
https://github.com/python/cpython
Revision c352e6c7446c894b13643f538db312092b351789 authored by Miss Islington (bot) on 04 February 2020, 22:06:42 UTC, committed by GitHub on 04 February 2020, 22:06:42 UTC
When called on a closed object, readinto() segfaults on account
of a write to a freed buffer:

    ==220553== Process terminating with default action of signal 11 (SIGSEGV): dumping core
    ==220553==  Access not within mapped region at address 0x2A
    ==220553==    at 0x48408A0: memmove (vg_replace_strmem.c:1272)
    ==220553==    by 0x58DB0C: _buffered_readinto_generic (bufferedio.c:972)
    ==220553==    by 0x58DCBA: _io__Buffered_readinto_impl (bufferedio.c:1053)
    ==220553==    by 0x58DCBA: _io__Buffered_readinto (bufferedio.c.h:253)

Reproducer:

    reader = open ("/dev/zero", "rb")
    _void  = reader.read (42)
    reader.close ()
    reader.readinto (bytearray (42)) GH-GH-GH- BANG!

The problem exists since 2012 when commit dc469454ec added code
to free the read buffer on close().

Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
(cherry picked from commit cb1c0746f277052e45a60d6c436a765e34722821)

Co-authored-by: Philipp Gesang <phg@phi-gamma.net>

Co-authored-by: Philipp Gesang <phg@phi-gamma.net>
1 parent 51332c4
History
Tip revision: c352e6c7446c894b13643f538db312092b351789 authored by Miss Islington (bot) on 04 February 2020, 22:06:42 UTC
closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18350)
Tip revision: c352e6c
File Mode Size
clinic
stringlib
README -rw-r--r-- 41 bytes
abstract.c -rw-r--r-- 80.9 KB
accu.c -rw-r--r-- 2.4 KB
boolobject.c -rw-r--r-- 6.5 KB
bytearrayobject.c -rw-r--r-- 69.3 KB
bytes_methods.c -rw-r--r-- 21.0 KB
bytesobject.c -rw-r--r-- 99.0 KB
capsule.c -rw-r--r-- 7.3 KB
cellobject.c -rw-r--r-- 4.8 KB
classobject.c -rw-r--r-- 18.1 KB
codeobject.c -rw-r--r-- 28.2 KB
complexobject.c -rw-r--r-- 31.7 KB
descrobject.c -rw-r--r-- 53.7 KB
dict-common.h -rw-r--r-- 2.2 KB
dictnotes.txt -rw-r--r-- 6.0 KB
dictobject.c -rw-r--r-- 131.9 KB
enumobject.c -rw-r--r-- 13.1 KB
exceptions.c -rw-r--r-- 86.1 KB
fileobject.c -rw-r--r-- 15.3 KB
floatobject.c -rw-r--r-- 70.7 KB
frameobject.c -rw-r--r-- 33.9 KB
funcobject.c -rw-r--r-- 30.4 KB
genobject.c -rw-r--r-- 67.9 KB
iterobject.c -rw-r--r-- 8.9 KB
listobject.c -rw-r--r-- 86.0 KB
listsort.txt -rw-r--r-- 34.9 KB
lnotab_notes.txt -rw-r--r-- 5.7 KB
longobject.c -rw-r--r-- 167.5 KB
memoryobject.c -rw-r--r-- 88.8 KB
methodobject.c -rw-r--r-- 15.4 KB
moduleobject.c -rw-r--r-- 22.6 KB
namespaceobject.c -rw-r--r-- 7.4 KB
object.c -rw-r--r-- 57.8 KB
obmalloc.c -rw-r--r-- 80.2 KB
odictobject.c -rw-r--r-- 75.8 KB
rangeobject.c -rw-r--r-- 37.1 KB
setobject.c -rw-r--r-- 73.0 KB
sliceobject.c -rw-r--r-- 19.2 KB
structseq.c -rw-r--r-- 12.9 KB
tupleobject.c -rw-r--r-- 29.9 KB
typeobject.c -rw-r--r-- 232.8 KB
typeslots.inc -rw-r--r-- 3.9 KB
typeslots.py -rwxr-xr-x 1.2 KB
unicodectype.c -rw-r--r-- 7.5 KB
unicodeobject.c -rw-r--r-- 457.5 KB
unicodetype_db.h -rw-r--r-- 234.1 KB
weakrefobject.c -rw-r--r-- 29.5 KB

README

back to top