diff options
author | Daniel Stenberg <daniel@haxx.se> | 2017-04-25 00:09:22 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-05-01 22:55:29 +0200 |
commit | c2ddc12d6086b522703c8b80a72ab791680f1a28 (patch) | |
tree | d710a4a2bbddc2c01c05f54f7e14d6eafe461331 /lib/url.c | |
parent | 349789e645a306a6ee467ef90a57f6cc306ca92e (diff) |
CURLOPT_BUFFERSIZE: 1024 bytes is now the minimum size
The buffer is needed to receive FTP, HTTP CONNECT responses etc so
already at this size things risk breaking and smaller is certainly not
wise.
Diffstat (limited to 'lib/url.c')
-rw-r--r-- | lib/url.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -2284,15 +2284,17 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option, * The application kindly asks for a differently sized receive buffer. * If it seems reasonable, we'll use it. */ - data->set.buffer_size = va_arg(param, long); + arg = va_arg(param, long); - if(data->set.buffer_size > MAX_BUFSIZE) - data->set.buffer_size = MAX_BUFSIZE; /* huge internal default */ - else if(data->set.buffer_size < 1) - data->set.buffer_size = BUFSIZE; + if(arg > MAX_BUFSIZE) + arg = MAX_BUFSIZE; /* huge internal default */ + else if(arg < 1) + arg = BUFSIZE; + else if(arg < MIN_BUFSIZE) + arg = BUFSIZE; /* Resize only if larger than default buffer size. */ - if(data->set.buffer_size > BUFSIZE) { + if(arg > BUFSIZE) { char *newbuff = realloc(data->state.buffer, data->set.buffer_size + 1); if(!newbuff) { DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n")); @@ -2301,6 +2303,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option, else data->state.buffer = newbuff; } + data->set.buffer_size = arg; break; |