summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-08-21 16:19:27 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-08-24 09:08:56 +0200
commitbc3b5bcf87f9fe16514f8cfd84cded24a367ac95 (patch)
tree539275ba98110c9e81a24edf7165fc27b8584a62
parentfab51852751598a9eccde6615d62194ab6840adc (diff)
downloadcurl-bc3b5bcf87f9fe16514f8cfd84cded24a367ac95.tar.gz
setopt: if the buffer exists, refuse the new BUFFERSIZE
The buffer only exists during transfer and then we shouldn't change the size (the setopt is not documented to work then). Reported-by: Harry Sintonen Closes #5842
-rw-r--r--lib/setopt.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/setopt.c b/lib/setopt.c
index d6213357c..768452ca1 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -2075,6 +2075,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* The application kindly asks for a differently sized receive buffer.
* If it seems reasonable, we'll use it.
*/
+ if(data->state.buffer)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
arg = va_arg(param, long);
if(arg > READBUFFER_MAX)
@@ -2084,18 +2087,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
else if(arg < READBUFFER_MIN)
arg = READBUFFER_MIN;
- /* Resize if new size */
- if((arg != data->set.buffer_size) && data->state.buffer) {
- char *newbuff = realloc(data->state.buffer, arg + 1);
- if(!newbuff) {
- DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
- result = CURLE_OUT_OF_MEMORY;
- }
- else
- data->state.buffer = newbuff;
- }
data->set.buffer_size = arg;
-
break;
case CURLOPT_UPLOAD_BUFFERSIZE: