mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
upload: missing rewind call could make libcurl hang
When an upload is done, there are two places where that can be detected and only one of them would rewind the input stream - which sometimes is necessary for example when doing NTLM HTTP POSTs and more. This could then end up libcurl hanging. Figured-out-by: Isaac Boukris Reported-by: Anatol Belski Fixes #741
This commit is contained in:
parent
7db9782dd6
commit
3e005a8555
@ -816,6 +816,20 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CURLcode done_sending(struct connectdata *conn,
|
||||||
|
struct SingleRequest *k)
|
||||||
|
{
|
||||||
|
k->keepon &= ~KEEP_SEND; /* we're done writing */
|
||||||
|
|
||||||
|
if(conn->bits.rewindaftersend) {
|
||||||
|
CURLcode result = Curl_readrewind(conn);
|
||||||
|
if(result)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send data to upload to the server, when the socket is writable.
|
* Send data to upload to the server, when the socket is writable.
|
||||||
*/
|
*/
|
||||||
@ -887,14 +901,9 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(nread<=0) {
|
else if(nread<=0) {
|
||||||
/* done */
|
result = done_sending(conn, k);
|
||||||
k->keepon &= ~KEEP_SEND; /* we're done writing */
|
if(result)
|
||||||
|
return result;
|
||||||
if(conn->bits.rewindaftersend) {
|
|
||||||
result = Curl_readrewind(conn);
|
|
||||||
if(result)
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,8 +1013,9 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
|
|||||||
data->req.upload_present = 0; /* no more bytes left */
|
data->req.upload_present = 0; /* no more bytes left */
|
||||||
|
|
||||||
if(k->upload_done) {
|
if(k->upload_done) {
|
||||||
/* switch off writing, we're done! */
|
result = done_sending(conn, k);
|
||||||
k->keepon &= ~KEEP_SEND; /* we're done writing */
|
if(result)
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user