Fix 'CVE-2018-1000122'

Merge: curl/curl@d52dc4760f
This commit is contained in:
Kawe Mazidjatari 2023-06-12 20:13:24 +02:00
parent 6069e9f00b
commit 2aee31375f

View File

@ -791,10 +791,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);