Skip to content

Commit

Permalink
readwrite: make sure excess reads don't go beyond buffer end
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Mar 12, 2018
1 parent ddb879c commit d52dc47
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/transfer.c
Expand Up @@ -808,10 +808,15 @@ static CURLcode readwrite_data(struct Curl_easy *data,

} /* if(!header and data to read) */

if(conn->handler->readwrite &&
(excess > 0 && !conn->bits.stream_was_rewound)) {
if(conn->handler->readwrite && excess && !conn->bits.stream_was_rewound) {
/* Parse the excess data */
k->str += nread;

if(&k->str[excess] > &k->buf[data->set.buffer_size]) {
/* the excess amount was too excessive(!), make sure
it doesn't read out of buffer */
excess = &k->buf[data->set.buffer_size] - k->str;
}
nread = (ssize_t)excess;

result = conn->handler->readwrite(data, conn, &nread, &readmore);
Expand Down

0 comments on commit d52dc47

Please sign in to comment.