1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 17:18:48 -05:00

pause: bail out on bad input

A NULL easy handle or an easy handle without an associated connection
cannot be paused or unpaused.

Closes #5050
This commit is contained in:
Daniel Stenberg 2020-03-06 10:12:22 +01:00
parent 3c3db98b6f
commit e54b1885d1
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -973,15 +973,21 @@ void curl_easy_reset(struct Curl_easy *data)
*/ */
CURLcode curl_easy_pause(struct Curl_easy *data, int action) CURLcode curl_easy_pause(struct Curl_easy *data, int action)
{ {
struct SingleRequest *k = &data->req; struct SingleRequest *k;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
int oldstate = k->keepon & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE); int oldstate;
int newstate;
/* first switch off both pause bits */ if(!GOOD_EASY_HANDLE(data) || !data->conn)
int newstate = k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE); /* crazy input, don't continue */
return CURLE_BAD_FUNCTION_ARGUMENT;
/* set the new desired pause bits */ k = &data->req;
newstate |= ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) | oldstate = k->keepon & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);
/* first switch off both pause bits then set the new pause bits */
newstate = (k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) |
((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |
((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0); ((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0);
if((newstate & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) == oldstate) { if((newstate & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) == oldstate) {