summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-11 13:31:33 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-11 13:31:33 (GMT)
commit32cfedeb1c378d6acf8e39308831f826f614a204 (patch)
treec5c133aee304b2bdf98a029b8f93d410fbeab25d /Modules/_io
parent5ea3d9370889b08a99ed1bdfdd40f9e89dd60adc (diff)
downloadcpython-32cfedeb1c378d6acf8e39308831f826f614a204.zip
cpython-32cfedeb1c378d6acf8e39308831f826f614a204.tar.gz
cpython-32cfedeb1c378d6acf8e39308831f826f614a204.tar.bz2
Issue #9550: a BufferedReader could issue an additional read when the
original read request had been satisfied, which can block indefinitely when the underlying raw IO channel is e.g. a socket. Report and original patch by Jason V. Miller.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bufferedio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 1dd1ec4..4678da9 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1383,7 +1383,10 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n)
self->pos = 0;
self->raw_pos = 0;
self->read_end = 0;
- while (self->read_end < self->buffer_size) {
+ /* NOTE: when the read is satisfied, we avoid issuing any additional
+ reads, which could block indefinitely (e.g. on a socket).
+ See issue #9550. */
+ while (remaining > 0 && self->read_end < self->buffer_size) {
Py_ssize_t r = _bufferedreader_fill_buffer(self);
if (r == -1)
goto error;