cpython/Modules/_io
Miss Islington (bot) c352e6c744
closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18350)
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 cb1c0746f2)

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

Co-authored-by: Philipp Gesang <phg@phi-gamma.net>
2020-02-04 14:06:42 -08:00
..
clinic Issue #27810: Regenerate Argument Clinic. 2016-09-11 21:25:45 +03:00
_iomodule.c Merge from 3.5. 2016-12-07 13:31:47 +02:00
_iomodule.h Issue #28217: Adds _testconsole module to test console input. Fixes some issues found by the tests. 2016-10-03 09:04:58 -07:00
bufferedio.c closes bpo-39510: Fix use-after-free in BufferedReader.readinto() (GH-18350) 2020-02-04 14:06:42 -08:00
bytesio.c [3.6] bpo-33029: Fix signatures of getter and setter functions. (GH-10746) (GH-10749) 2018-11-27 20:38:36 +02:00
fileio.c [3.6] bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705) (GH-9937) 2018-10-18 01:52:21 +02:00
iobase.c bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an exception set (GH-8282). (GH-8312) 2018-07-17 10:33:14 +03:00
stringio.c bpo-25862: Fix several bugs in the _io module. (GH-8026) 2018-06-30 11:25:50 -07:00
textio.c bpo-35062: Fix parsing _io.IncrementalNewlineDecoder's *translate* argument. (GH-10217) 2018-10-31 05:36:34 -07:00
winconsoleio.c bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) (GH-11020) (GH-11026) 2018-12-07 18:09:23 +02:00