Line | Count | Source (jump to first uncovered line) |
1 | | /*************************************************************************** |
2 | | * _ _ ____ _ |
3 | | * Project ___| | | | _ \| | |
4 | | * / __| | | | |_) | | |
5 | | * | (__| |_| | _ <| |___ |
6 | | * \___|\___/|_| \_\_____| |
7 | | * |
8 | | * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. |
9 | | * |
10 | | * This software is licensed as described in the file COPYING, which |
11 | | * you should have received as part of this distribution. The terms |
12 | | * are also available at https://curl.se/docs/copyright.html. |
13 | | * |
14 | | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
15 | | * copies of the Software, and permit persons to whom the Software is |
16 | | * furnished to do so, under the terms of the COPYING file. |
17 | | * |
18 | | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
19 | | * KIND, either express or implied. |
20 | | * |
21 | | * SPDX-License-Identifier: curl |
22 | | * |
23 | | ***************************************************************************/ |
24 | | |
25 | | #include "curl_setup.h" |
26 | | |
27 | | #include <limits.h> |
28 | | |
29 | | #ifdef HAVE_NETINET_IN_H |
30 | | #include <netinet/in.h> |
31 | | #endif |
32 | | |
33 | | #ifdef HAVE_LINUX_TCP_H |
34 | | #include <linux/tcp.h> |
35 | | #elif defined(HAVE_NETINET_TCP_H) |
36 | | #include <netinet/tcp.h> |
37 | | #endif |
38 | | |
39 | | #include "urldata.h" |
40 | | #include "url.h" |
41 | | #include "progress.h" |
42 | | #include "content_encoding.h" |
43 | | #include "strcase.h" |
44 | | #include "share.h" |
45 | | #include "vtls/vtls.h" |
46 | | #include "warnless.h" |
47 | | #include "sendf.h" |
48 | | #include "http2.h" |
49 | | #include "setopt.h" |
50 | | #include "multiif.h" |
51 | | #include "altsvc.h" |
52 | | #include "hsts.h" |
53 | | |
54 | | /* The last 3 #include files should be in this order */ |
55 | | #include "curl_printf.h" |
56 | | #include "curl_memory.h" |
57 | | #include "memdebug.h" |
58 | | |
59 | | CURLcode Curl_setstropt(char **charp, const char *s) |
60 | 1.54k | { |
61 | | /* Release the previous storage at `charp' and replace by a dynamic storage |
62 | | copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */ |
63 | | |
64 | 1.54k | Curl_safefree(*charp); |
65 | | |
66 | 1.54k | if(s) { |
67 | 1.53k | if(strlen(s) > CURL_MAX_INPUT_LENGTH) |
68 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
69 | | |
70 | 1.53k | *charp = strdup(s); |
71 | 1.53k | if(!*charp) |
72 | 0 | return CURLE_OUT_OF_MEMORY; |
73 | 1.53k | } |
74 | | |
75 | 1.54k | return CURLE_OK; |
76 | 1.54k | } |
77 | | |
78 | | CURLcode Curl_setblobopt(struct curl_blob **blobp, |
79 | | const struct curl_blob *blob) |
80 | 0 | { |
81 | | /* free the previous storage at `blobp' and replace by a dynamic storage |
82 | | copy of blob. If CURL_BLOB_COPY is set, the data is copied. */ |
83 | |
|
84 | 0 | Curl_safefree(*blobp); |
85 | |
|
86 | 0 | if(blob) { |
87 | 0 | struct curl_blob *nblob; |
88 | 0 | if(blob->len > CURL_MAX_INPUT_LENGTH) |
89 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
90 | 0 | nblob = (struct curl_blob *) |
91 | 0 | malloc(sizeof(struct curl_blob) + |
92 | 0 | ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0)); |
93 | 0 | if(!nblob) |
94 | 0 | return CURLE_OUT_OF_MEMORY; |
95 | 0 | *nblob = *blob; |
96 | 0 | if(blob->flags & CURL_BLOB_COPY) { |
97 | | /* put the data after the blob struct in memory */ |
98 | 0 | nblob->data = (char *)nblob + sizeof(struct curl_blob); |
99 | 0 | memcpy(nblob->data, blob->data, blob->len); |
100 | 0 | } |
101 | |
|
102 | 0 | *blobp = nblob; |
103 | 0 | return CURLE_OK; |
104 | 0 | } |
105 | | |
106 | 0 | return CURLE_OK; |
107 | 0 | } |
108 | | |
109 | | static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp) |
110 | 41 | { |
111 | 41 | CURLcode result = CURLE_OK; |
112 | 41 | char *user = NULL; |
113 | 41 | char *passwd = NULL; |
114 | | |
115 | | /* Parse the login details if specified. It not then we treat NULL as a hint |
116 | | to clear the existing data */ |
117 | 41 | if(option) { |
118 | 41 | result = Curl_parse_login_details(option, strlen(option), |
119 | 41 | (userp ? &user : NULL), |
120 | 41 | (passwdp ? &passwd : NULL), |
121 | 41 | NULL); |
122 | 41 | } |
123 | | |
124 | 41 | if(!result) { |
125 | | /* Store the username part of option if required */ |
126 | 41 | if(userp) { |
127 | 41 | if(!user && option && option[0] == ':') { |
128 | | /* Allocate an empty string instead of returning NULL as user name */ |
129 | 0 | user = strdup(""); |
130 | 0 | if(!user) |
131 | 0 | result = CURLE_OUT_OF_MEMORY; |
132 | 0 | } |
133 | | |
134 | 41 | Curl_safefree(*userp); |
135 | 41 | *userp = user; |
136 | 41 | } |
137 | | |
138 | | /* Store the password part of option if required */ |
139 | 41 | if(passwdp) { |
140 | 41 | Curl_safefree(*passwdp); |
141 | 41 | *passwdp = passwd; |
142 | 41 | } |
143 | 41 | } |
144 | | |
145 | 41 | return result; |
146 | 41 | } |
147 | | |
148 | | #define C_SSLVERSION_VALUE(x) (x & 0xffff) |
149 | | #define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000) |
150 | | |
151 | | static CURLcode protocol2num(const char *str, curl_prot_t *val) |
152 | 0 | { |
153 | 0 | if(!str) |
154 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
155 | | |
156 | 0 | if(curl_strequal(str, "all")) { |
157 | 0 | *val = ~(curl_prot_t) 0; |
158 | 0 | return CURLE_OK; |
159 | 0 | } |
160 | | |
161 | 0 | *val = 0; |
162 | |
|
163 | 0 | do { |
164 | 0 | const char *token = str; |
165 | 0 | size_t tlen; |
166 | |
|
167 | 0 | str = strchr(str, ','); |
168 | 0 | tlen = str? (size_t) (str - token): strlen(token); |
169 | 0 | if(tlen) { |
170 | 0 | const struct Curl_handler *h = Curl_builtin_scheme(token, tlen); |
171 | |
|
172 | 0 | if(!h) |
173 | 0 | return CURLE_UNSUPPORTED_PROTOCOL; |
174 | | |
175 | 0 | *val |= h->protocol; |
176 | 0 | } |
177 | 0 | } while(str && str++); |
178 | | |
179 | 0 | if(!*val) |
180 | | /* no protocol listed */ |
181 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
182 | 0 | return CURLE_OK; |
183 | 0 | } |
184 | | |
185 | | /* |
186 | | * Do not make Curl_vsetopt() static: it is called from |
187 | | * packages/OS400/ccsidcurl.c. |
188 | | */ |
189 | | CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) |
190 | 8.28k | { |
191 | 8.28k | char *argptr; |
192 | 8.28k | CURLcode result = CURLE_OK; |
193 | 8.28k | long arg; |
194 | 8.28k | unsigned long uarg; |
195 | 8.28k | curl_off_t bigsize; |
196 | | |
197 | 8.28k | switch(option) { |
198 | 0 | case CURLOPT_DNS_CACHE_TIMEOUT: |
199 | 0 | arg = va_arg(param, long); |
200 | 0 | if(arg < -1) |
201 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
202 | 0 | else if(arg > INT_MAX) |
203 | 0 | arg = INT_MAX; |
204 | | |
205 | 0 | data->set.dns_cache_timeout = (int)arg; |
206 | 0 | break; |
207 | 0 | case CURLOPT_CA_CACHE_TIMEOUT: |
208 | 0 | arg = va_arg(param, long); |
209 | 0 | if(arg < -1) |
210 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
211 | 0 | else if(arg > INT_MAX) |
212 | 0 | arg = INT_MAX; |
213 | | |
214 | 0 | data->set.general_ssl.ca_cache_timeout = (int)arg; |
215 | 0 | break; |
216 | 0 | case CURLOPT_DNS_USE_GLOBAL_CACHE: |
217 | | /* deprecated */ |
218 | 0 | break; |
219 | 0 | case CURLOPT_SSL_CIPHER_LIST: |
220 | | /* set a list of cipher we want to use in the SSL connection */ |
221 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST], |
222 | 0 | va_arg(param, char *)); |
223 | 0 | break; |
224 | 0 | #ifndef CURL_DISABLE_PROXY |
225 | 0 | case CURLOPT_PROXY_SSL_CIPHER_LIST: |
226 | | /* set a list of cipher we want to use in the SSL connection for proxy */ |
227 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_PROXY], |
228 | 0 | va_arg(param, char *)); |
229 | 0 | break; |
230 | 0 | #endif |
231 | 0 | case CURLOPT_TLS13_CIPHERS: |
232 | 0 | if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES)) { |
233 | | /* set preferred list of TLS 1.3 cipher suites */ |
234 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST], |
235 | 0 | va_arg(param, char *)); |
236 | 0 | } |
237 | 0 | else |
238 | 0 | return CURLE_NOT_BUILT_IN; |
239 | 0 | break; |
240 | 0 | #ifndef CURL_DISABLE_PROXY |
241 | 0 | case CURLOPT_PROXY_TLS13_CIPHERS: |
242 | 0 | if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES)) { |
243 | | /* set preferred list of TLS 1.3 cipher suites for proxy */ |
244 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY], |
245 | 0 | va_arg(param, char *)); |
246 | 0 | } |
247 | 0 | else |
248 | 0 | return CURLE_NOT_BUILT_IN; |
249 | 0 | break; |
250 | 0 | #endif |
251 | 0 | case CURLOPT_RANDOM_FILE: |
252 | 0 | break; |
253 | 0 | case CURLOPT_EGDSOCKET: |
254 | 0 | break; |
255 | 0 | case CURLOPT_MAXCONNECTS: |
256 | | /* |
257 | | * Set the absolute number of maximum simultaneous alive connection that |
258 | | * libcurl is allowed to have. |
259 | | */ |
260 | 0 | arg = va_arg(param, long); |
261 | 0 | if(arg < 0) |
262 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
263 | 0 | data->set.maxconnects = arg; |
264 | 0 | break; |
265 | 0 | case CURLOPT_FORBID_REUSE: |
266 | | /* |
267 | | * When this transfer is done, it must not be left to be reused by a |
268 | | * subsequent transfer but shall be closed immediately. |
269 | | */ |
270 | 0 | data->set.reuse_forbid = (0 != va_arg(param, long)) ? TRUE : FALSE; |
271 | 0 | break; |
272 | 0 | case CURLOPT_FRESH_CONNECT: |
273 | | /* |
274 | | * This transfer shall not use a previously cached connection but |
275 | | * should be made with a fresh new connect! |
276 | | */ |
277 | 0 | data->set.reuse_fresh = (0 != va_arg(param, long)) ? TRUE : FALSE; |
278 | 0 | break; |
279 | 0 | case CURLOPT_VERBOSE: |
280 | | /* |
281 | | * Verbose means infof() calls that give a lot of information about |
282 | | * the connection and transfer procedures as well as internal choices. |
283 | | */ |
284 | 0 | data->set.verbose = (0 != va_arg(param, long)) ? TRUE : FALSE; |
285 | 0 | break; |
286 | 34 | case CURLOPT_HEADER: |
287 | | /* |
288 | | * Set to include the header in the general data output stream. |
289 | | */ |
290 | 34 | data->set.include_header = (0 != va_arg(param, long)) ? TRUE : FALSE; |
291 | 34 | break; |
292 | 0 | case CURLOPT_NOPROGRESS: |
293 | | /* |
294 | | * Shut off the internal supported progress meter |
295 | | */ |
296 | 0 | data->set.hide_progress = (0 != va_arg(param, long)) ? TRUE : FALSE; |
297 | 0 | if(data->set.hide_progress) |
298 | 0 | data->progress.flags |= PGRS_HIDE; |
299 | 0 | else |
300 | 0 | data->progress.flags &= ~PGRS_HIDE; |
301 | 0 | break; |
302 | 41 | case CURLOPT_NOBODY: |
303 | | /* |
304 | | * Do not include the body part in the output data stream. |
305 | | */ |
306 | 41 | data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE; |
307 | 41 | #ifndef CURL_DISABLE_HTTP |
308 | 41 | if(data->set.opt_no_body) |
309 | | /* in HTTP lingo, no body means using the HEAD request... */ |
310 | 38 | data->set.method = HTTPREQ_HEAD; |
311 | 3 | else if(data->set.method == HTTPREQ_HEAD) |
312 | 0 | data->set.method = HTTPREQ_GET; |
313 | 41 | #endif |
314 | 41 | break; |
315 | 0 | case CURLOPT_FAILONERROR: |
316 | | /* |
317 | | * Don't output the >=400 error code HTML-page, but instead only |
318 | | * return error. |
319 | | */ |
320 | 0 | data->set.http_fail_on_error = (0 != va_arg(param, long)) ? TRUE : FALSE; |
321 | 0 | break; |
322 | 0 | case CURLOPT_KEEP_SENDING_ON_ERROR: |
323 | 0 | data->set.http_keep_sending_on_error = (0 != va_arg(param, long)) ? |
324 | 0 | TRUE : FALSE; |
325 | 0 | break; |
326 | 30 | case CURLOPT_UPLOAD: |
327 | 30 | case CURLOPT_PUT: |
328 | | /* |
329 | | * We want to sent data to the remote host. If this is HTTP, that equals |
330 | | * using the PUT request. |
331 | | */ |
332 | 30 | data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE; |
333 | 30 | if(data->set.upload) { |
334 | | /* If this is HTTP, PUT is what's needed to "upload" */ |
335 | 30 | data->set.method = HTTPREQ_PUT; |
336 | 30 | data->set.opt_no_body = FALSE; /* this is implied */ |
337 | 30 | } |
338 | 0 | else |
339 | | /* In HTTP, the opposite of upload is GET (unless NOBODY is true as |
340 | | then this can be changed to HEAD later on) */ |
341 | 0 | data->set.method = HTTPREQ_GET; |
342 | 30 | break; |
343 | 0 | case CURLOPT_REQUEST_TARGET: |
344 | 0 | result = Curl_setstropt(&data->set.str[STRING_TARGET], |
345 | 0 | va_arg(param, char *)); |
346 | 0 | break; |
347 | 0 | case CURLOPT_FILETIME: |
348 | | /* |
349 | | * Try to get the file time of the remote document. The time will |
350 | | * later (possibly) become available using curl_easy_getinfo(). |
351 | | */ |
352 | 0 | data->set.get_filetime = (0 != va_arg(param, long)) ? TRUE : FALSE; |
353 | 0 | break; |
354 | 0 | case CURLOPT_SERVER_RESPONSE_TIMEOUT: |
355 | | /* |
356 | | * Option that specifies how quickly a server response must be obtained |
357 | | * before it is considered failure. For pingpong protocols. |
358 | | */ |
359 | 0 | arg = va_arg(param, long); |
360 | 0 | if((arg >= 0) && (arg <= (INT_MAX/1000))) |
361 | 0 | data->set.server_response_timeout = (unsigned int)arg * 1000; |
362 | 0 | else |
363 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
364 | 0 | break; |
365 | 0 | #ifndef CURL_DISABLE_TFTP |
366 | 0 | case CURLOPT_TFTP_NO_OPTIONS: |
367 | | /* |
368 | | * Option that prevents libcurl from sending TFTP option requests to the |
369 | | * server. |
370 | | */ |
371 | 0 | data->set.tftp_no_options = va_arg(param, long) != 0; |
372 | 0 | break; |
373 | 0 | case CURLOPT_TFTP_BLKSIZE: |
374 | | /* |
375 | | * TFTP option that specifies the block size to use for data transmission. |
376 | | */ |
377 | 0 | arg = va_arg(param, long); |
378 | 0 | if(arg < 0) |
379 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
380 | 0 | data->set.tftp_blksize = arg; |
381 | 0 | break; |
382 | 0 | #endif |
383 | 0 | #ifndef CURL_DISABLE_NETRC |
384 | 44 | case CURLOPT_NETRC: |
385 | | /* |
386 | | * Parse the $HOME/.netrc file |
387 | | */ |
388 | 44 | arg = va_arg(param, long); |
389 | 44 | if((arg < CURL_NETRC_IGNORED) || (arg >= CURL_NETRC_LAST)) |
390 | 40 | return CURLE_BAD_FUNCTION_ARGUMENT; |
391 | 4 | data->set.use_netrc = (unsigned char)arg; |
392 | 4 | break; |
393 | 0 | case CURLOPT_NETRC_FILE: |
394 | | /* |
395 | | * Use this file instead of the $HOME/.netrc file |
396 | | */ |
397 | 0 | result = Curl_setstropt(&data->set.str[STRING_NETRC_FILE], |
398 | 0 | va_arg(param, char *)); |
399 | 0 | break; |
400 | 0 | #endif |
401 | 0 | case CURLOPT_TRANSFERTEXT: |
402 | | /* |
403 | | * This option was previously named 'FTPASCII'. Renamed to work with |
404 | | * more protocols than merely FTP. |
405 | | * |
406 | | * Transfer using ASCII (instead of BINARY). |
407 | | */ |
408 | 0 | data->set.prefer_ascii = (0 != va_arg(param, long)) ? TRUE : FALSE; |
409 | 0 | break; |
410 | 0 | case CURLOPT_TIMECONDITION: |
411 | | /* |
412 | | * Set HTTP time condition. This must be one of the defines in the |
413 | | * curl/curl.h header file. |
414 | | */ |
415 | 0 | arg = va_arg(param, long); |
416 | 0 | if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST)) |
417 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
418 | 0 | data->set.timecondition = (unsigned char)(curl_TimeCond)arg; |
419 | 0 | break; |
420 | 0 | case CURLOPT_TIMEVALUE: |
421 | | /* |
422 | | * This is the value to compare with the remote document with the |
423 | | * method set with CURLOPT_TIMECONDITION |
424 | | */ |
425 | 0 | data->set.timevalue = (time_t)va_arg(param, long); |
426 | 0 | break; |
427 | | |
428 | 0 | case CURLOPT_TIMEVALUE_LARGE: |
429 | | /* |
430 | | * This is the value to compare with the remote document with the |
431 | | * method set with CURLOPT_TIMECONDITION |
432 | | */ |
433 | 0 | data->set.timevalue = (time_t)va_arg(param, curl_off_t); |
434 | 0 | break; |
435 | | |
436 | 0 | case CURLOPT_SSLVERSION: |
437 | 0 | #ifndef CURL_DISABLE_PROXY |
438 | 0 | case CURLOPT_PROXY_SSLVERSION: |
439 | 0 | #endif |
440 | | /* |
441 | | * Set explicit SSL version to try to connect with, as some SSL |
442 | | * implementations are lame. |
443 | | */ |
444 | | #ifdef USE_SSL |
445 | | { |
446 | | long version, version_max; |
447 | | struct ssl_primary_config *primary = &data->set.ssl.primary; |
448 | | #ifndef CURL_DISABLE_PROXY |
449 | | if(option != CURLOPT_SSLVERSION) |
450 | | primary = &data->set.proxy_ssl.primary; |
451 | | #endif |
452 | | |
453 | | arg = va_arg(param, long); |
454 | | |
455 | | version = C_SSLVERSION_VALUE(arg); |
456 | | version_max = C_SSLVERSION_MAX_VALUE(arg); |
457 | | |
458 | | if(version < CURL_SSLVERSION_DEFAULT || |
459 | | version == CURL_SSLVERSION_SSLv2 || |
460 | | version == CURL_SSLVERSION_SSLv3 || |
461 | | version >= CURL_SSLVERSION_LAST || |
462 | | version_max < CURL_SSLVERSION_MAX_NONE || |
463 | | version_max >= CURL_SSLVERSION_MAX_LAST) |
464 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
465 | | |
466 | | primary->version = (unsigned char)version; |
467 | | primary->version_max = (unsigned int)version_max; |
468 | | } |
469 | | #else |
470 | 0 | result = CURLE_NOT_BUILT_IN; |
471 | 0 | #endif |
472 | 0 | break; |
473 | | |
474 | | /* MQTT "borrows" some of the HTTP options */ |
475 | 0 | #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MQTT) |
476 | 0 | case CURLOPT_COPYPOSTFIELDS: |
477 | | /* |
478 | | * A string with POST data. Makes curl HTTP POST. Even if it is NULL. |
479 | | * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to |
480 | | * CURLOPT_COPYPOSTFIELDS and not altered later. |
481 | | */ |
482 | 0 | argptr = va_arg(param, char *); |
483 | |
|
484 | 0 | if(!argptr || data->set.postfieldsize == -1) |
485 | 0 | result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr); |
486 | 0 | else { |
487 | | /* |
488 | | * Check that requested length does not overflow the size_t type. |
489 | | */ |
490 | |
|
491 | 0 | if((data->set.postfieldsize < 0) || |
492 | 0 | ((sizeof(curl_off_t) != sizeof(size_t)) && |
493 | 0 | (data->set.postfieldsize > (curl_off_t)((size_t)-1)))) |
494 | 0 | result = CURLE_OUT_OF_MEMORY; |
495 | 0 | else { |
496 | 0 | char *p; |
497 | |
|
498 | 0 | (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); |
499 | | |
500 | | /* Allocate even when size == 0. This satisfies the need of possible |
501 | | later address compare to detect the COPYPOSTFIELDS mode, and |
502 | | to mark that postfields is used rather than read function or |
503 | | form data. |
504 | | */ |
505 | 0 | p = malloc((size_t)(data->set.postfieldsize? |
506 | 0 | data->set.postfieldsize:1)); |
507 | |
|
508 | 0 | if(!p) |
509 | 0 | result = CURLE_OUT_OF_MEMORY; |
510 | 0 | else { |
511 | 0 | if(data->set.postfieldsize) |
512 | 0 | memcpy(p, argptr, (size_t)data->set.postfieldsize); |
513 | |
|
514 | 0 | data->set.str[STRING_COPYPOSTFIELDS] = p; |
515 | 0 | } |
516 | 0 | } |
517 | 0 | } |
518 | |
|
519 | 0 | data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS]; |
520 | 0 | data->set.method = HTTPREQ_POST; |
521 | 0 | break; |
522 | | |
523 | 8 | case CURLOPT_POSTFIELDS: |
524 | | /* |
525 | | * Like above, but use static data instead of copying it. |
526 | | */ |
527 | 8 | data->set.postfields = va_arg(param, void *); |
528 | | /* Release old copied data. */ |
529 | 8 | (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); |
530 | 8 | data->set.method = HTTPREQ_POST; |
531 | 8 | break; |
532 | | |
533 | 0 | case CURLOPT_POSTFIELDSIZE: |
534 | | /* |
535 | | * The size of the POSTFIELD data to prevent libcurl to do strlen() to |
536 | | * figure it out. Enables binary posts. |
537 | | */ |
538 | 0 | bigsize = va_arg(param, long); |
539 | 0 | if(bigsize < -1) |
540 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
541 | | |
542 | 0 | if(data->set.postfieldsize < bigsize && |
543 | 0 | data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) { |
544 | | /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */ |
545 | 0 | (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); |
546 | 0 | data->set.postfields = NULL; |
547 | 0 | } |
548 | |
|
549 | 0 | data->set.postfieldsize = bigsize; |
550 | 0 | break; |
551 | | |
552 | 0 | case CURLOPT_POSTFIELDSIZE_LARGE: |
553 | | /* |
554 | | * The size of the POSTFIELD data to prevent libcurl to do strlen() to |
555 | | * figure it out. Enables binary posts. |
556 | | */ |
557 | 0 | bigsize = va_arg(param, curl_off_t); |
558 | 0 | if(bigsize < -1) |
559 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
560 | | |
561 | 0 | if(data->set.postfieldsize < bigsize && |
562 | 0 | data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) { |
563 | | /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */ |
564 | 0 | (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); |
565 | 0 | data->set.postfields = NULL; |
566 | 0 | } |
567 | |
|
568 | 0 | data->set.postfieldsize = bigsize; |
569 | 0 | break; |
570 | 0 | #endif |
571 | 0 | #ifndef CURL_DISABLE_HTTP |
572 | 0 | case CURLOPT_AUTOREFERER: |
573 | | /* |
574 | | * Switch on automatic referer that gets set if curl follows locations. |
575 | | */ |
576 | 0 | data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE; |
577 | 0 | break; |
578 | | |
579 | 15 | case CURLOPT_ACCEPT_ENCODING: |
580 | | /* |
581 | | * String to use at the value of Accept-Encoding header. |
582 | | * |
583 | | * If the encoding is set to "" we use an Accept-Encoding header that |
584 | | * encompasses all the encodings we support. |
585 | | * If the encoding is set to NULL we don't send an Accept-Encoding header |
586 | | * and ignore an received Content-Encoding header. |
587 | | * |
588 | | */ |
589 | 15 | argptr = va_arg(param, char *); |
590 | 15 | if(argptr && !*argptr) { |
591 | 7 | argptr = Curl_all_content_encodings(); |
592 | 7 | if(!argptr) |
593 | 0 | result = CURLE_OUT_OF_MEMORY; |
594 | 7 | else { |
595 | 7 | result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr); |
596 | 7 | free(argptr); |
597 | 7 | } |
598 | 7 | } |
599 | 8 | else |
600 | 8 | result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr); |
601 | 15 | break; |
602 | | |
603 | 0 | case CURLOPT_TRANSFER_ENCODING: |
604 | 0 | data->set.http_transfer_encoding = (0 != va_arg(param, long)) ? |
605 | 0 | TRUE : FALSE; |
606 | 0 | break; |
607 | | |
608 | 37 | case CURLOPT_FOLLOWLOCATION: |
609 | | /* |
610 | | * Follow Location: header hints on an HTTP-server. |
611 | | */ |
612 | 37 | data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE; |
613 | 37 | break; |
614 | | |
615 | 0 | case CURLOPT_UNRESTRICTED_AUTH: |
616 | | /* |
617 | | * Send authentication (user+password) when following locations, even when |
618 | | * hostname changed. |
619 | | */ |
620 | 0 | data->set.allow_auth_to_other_hosts = |
621 | 0 | (0 != va_arg(param, long)) ? TRUE : FALSE; |
622 | 0 | break; |
623 | | |
624 | 0 | case CURLOPT_MAXREDIRS: |
625 | | /* |
626 | | * The maximum amount of hops you allow curl to follow Location: |
627 | | * headers. This should mostly be used to detect never-ending loops. |
628 | | */ |
629 | 0 | arg = va_arg(param, long); |
630 | 0 | if(arg < -1) |
631 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
632 | 0 | data->set.maxredirs = arg; |
633 | 0 | break; |
634 | | |
635 | 0 | case CURLOPT_POSTREDIR: |
636 | | /* |
637 | | * Set the behavior of POST when redirecting |
638 | | * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302 |
639 | | * CURL_REDIR_POST_301 - POST is kept as POST after 301 |
640 | | * CURL_REDIR_POST_302 - POST is kept as POST after 302 |
641 | | * CURL_REDIR_POST_303 - POST is kept as POST after 303 |
642 | | * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303 |
643 | | * other - POST is kept as POST after 301 and 302 |
644 | | */ |
645 | 0 | arg = va_arg(param, long); |
646 | 0 | if(arg < CURL_REDIR_GET_ALL) |
647 | | /* no return error on too high numbers since the bitmask could be |
648 | | extended in a future */ |
649 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
650 | 0 | data->set.keep_post = arg & CURL_REDIR_POST_ALL; |
651 | 0 | break; |
652 | | |
653 | 34 | case CURLOPT_POST: |
654 | | /* Does this option serve a purpose anymore? Yes it does, when |
655 | | CURLOPT_POSTFIELDS isn't used and the POST data is read off the |
656 | | callback! */ |
657 | 34 | if(va_arg(param, long)) { |
658 | 32 | data->set.method = HTTPREQ_POST; |
659 | 32 | data->set.opt_no_body = FALSE; /* this is implied */ |
660 | 32 | } |
661 | 2 | else |
662 | 2 | data->set.method = HTTPREQ_GET; |
663 | 34 | data->set.upload = FALSE; |
664 | 34 | break; |
665 | | |
666 | 0 | #ifndef CURL_DISABLE_MIME |
667 | 35 | case CURLOPT_HTTPPOST: |
668 | | /* |
669 | | * Set to make us do HTTP POST |
670 | | */ |
671 | 35 | data->set.httppost = va_arg(param, struct curl_httppost *); |
672 | 35 | data->set.method = HTTPREQ_POST_FORM; |
673 | 35 | data->set.opt_no_body = FALSE; /* this is implied */ |
674 | 35 | break; |
675 | 0 | #endif |
676 | | |
677 | 0 | case CURLOPT_AWS_SIGV4: |
678 | | /* |
679 | | * String that is merged to some authentication |
680 | | * parameters are used by the algorithm. |
681 | | */ |
682 | 0 | result = Curl_setstropt(&data->set.str[STRING_AWS_SIGV4], |
683 | 0 | va_arg(param, char *)); |
684 | | /* |
685 | | * Basic been set by default it need to be unset here |
686 | | */ |
687 | 0 | if(data->set.str[STRING_AWS_SIGV4]) |
688 | 0 | data->set.httpauth = CURLAUTH_AWS_SIGV4; |
689 | 0 | break; |
690 | | |
691 | 0 | case CURLOPT_REFERER: |
692 | | /* |
693 | | * String to set in the HTTP Referer: field. |
694 | | */ |
695 | 0 | if(data->state.referer_alloc) { |
696 | 0 | Curl_safefree(data->state.referer); |
697 | 0 | data->state.referer_alloc = FALSE; |
698 | 0 | } |
699 | 0 | result = Curl_setstropt(&data->set.str[STRING_SET_REFERER], |
700 | 0 | va_arg(param, char *)); |
701 | 0 | data->state.referer = data->set.str[STRING_SET_REFERER]; |
702 | 0 | break; |
703 | | |
704 | 4 | case CURLOPT_USERAGENT: |
705 | | /* |
706 | | * String to use in the HTTP User-Agent field |
707 | | */ |
708 | 4 | result = Curl_setstropt(&data->set.str[STRING_USERAGENT], |
709 | 4 | va_arg(param, char *)); |
710 | 4 | break; |
711 | | |
712 | 0 | #ifndef CURL_DISABLE_PROXY |
713 | 0 | case CURLOPT_PROXYHEADER: |
714 | | /* |
715 | | * Set a list with proxy headers to use (or replace internals with) |
716 | | * |
717 | | * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a |
718 | | * long time we remain doing it this way until CURLOPT_PROXYHEADER is |
719 | | * used. As soon as this option has been used, if set to anything but |
720 | | * NULL, custom headers for proxies are only picked from this list. |
721 | | * |
722 | | * Set this option to NULL to restore the previous behavior. |
723 | | */ |
724 | 0 | data->set.proxyheaders = va_arg(param, struct curl_slist *); |
725 | 0 | break; |
726 | 0 | #endif |
727 | 0 | case CURLOPT_HEADEROPT: |
728 | | /* |
729 | | * Set header option. |
730 | | */ |
731 | 0 | arg = va_arg(param, long); |
732 | 0 | data->set.sep_headers = (bool)((arg & CURLHEADER_SEPARATE)? TRUE: FALSE); |
733 | 0 | break; |
734 | | |
735 | 0 | #if !defined(CURL_DISABLE_COOKIES) |
736 | 5 | case CURLOPT_COOKIE: |
737 | | /* |
738 | | * Cookie string to send to the remote server in the request. |
739 | | */ |
740 | 5 | result = Curl_setstropt(&data->set.str[STRING_COOKIE], |
741 | 5 | va_arg(param, char *)); |
742 | 5 | break; |
743 | | |
744 | 690 | case CURLOPT_COOKIEFILE: |
745 | | /* |
746 | | * Set cookie file to read and parse. Can be used multiple times. |
747 | | */ |
748 | 690 | argptr = (char *)va_arg(param, void *); |
749 | 690 | if(argptr) { |
750 | 690 | struct curl_slist *cl; |
751 | | /* general protection against mistakes and abuse */ |
752 | 690 | if(strlen(argptr) > CURL_MAX_INPUT_LENGTH) |
753 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
754 | | /* append the cookie file name to the list of file names, and deal with |
755 | | them later */ |
756 | 690 | cl = curl_slist_append(data->set.cookielist, argptr); |
757 | 690 | if(!cl) { |
758 | 0 | curl_slist_free_all(data->set.cookielist); |
759 | 0 | data->set.cookielist = NULL; |
760 | 0 | return CURLE_OUT_OF_MEMORY; |
761 | 0 | } |
762 | 690 | data->set.cookielist = cl; /* store the list for later use */ |
763 | 690 | } |
764 | 0 | else { |
765 | | /* clear the list of cookie files */ |
766 | 0 | curl_slist_free_all(data->set.cookielist); |
767 | 0 | data->set.cookielist = NULL; |
768 | |
|
769 | 0 | if(!data->share || !data->share->cookies) { |
770 | | /* throw away all existing cookies if this isn't a shared cookie |
771 | | container */ |
772 | 0 | Curl_cookie_clearall(data->cookies); |
773 | 0 | Curl_cookie_cleanup(data->cookies); |
774 | 0 | } |
775 | | /* disable the cookie engine */ |
776 | 0 | data->cookies = NULL; |
777 | 0 | } |
778 | 690 | break; |
779 | | |
780 | 690 | case CURLOPT_COOKIEJAR: |
781 | | /* |
782 | | * Set cookie file name to dump all cookies to when we're done. |
783 | | */ |
784 | 690 | { |
785 | 690 | struct CookieInfo *newcookies; |
786 | 690 | result = Curl_setstropt(&data->set.str[STRING_COOKIEJAR], |
787 | 690 | va_arg(param, char *)); |
788 | | |
789 | | /* |
790 | | * Activate the cookie parser. This may or may not already |
791 | | * have been made. |
792 | | */ |
793 | 690 | newcookies = Curl_cookie_init(data, NULL, data->cookies, |
794 | 690 | data->set.cookiesession); |
795 | 690 | if(!newcookies) |
796 | 0 | result = CURLE_OUT_OF_MEMORY; |
797 | 690 | data->cookies = newcookies; |
798 | 690 | } |
799 | 690 | break; |
800 | | |
801 | 0 | case CURLOPT_COOKIESESSION: |
802 | | /* |
803 | | * Set this option to TRUE to start a new "cookie session". It will |
804 | | * prevent the forthcoming read-cookies-from-file actions to accept |
805 | | * cookies that are marked as being session cookies, as they belong to a |
806 | | * previous session. |
807 | | * |
808 | | * In the original Netscape cookie spec, "session cookies" are cookies |
809 | | * with no expire date set. RFC2109 describes the same action if no |
810 | | * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds |
811 | | * a 'Discard' action that can enforce the discard even for cookies that |
812 | | * have a Max-Age. |
813 | | * |
814 | | * We run mostly with the original cookie spec, as hardly anyone implements |
815 | | * anything else. |
816 | | */ |
817 | 0 | data->set.cookiesession = (0 != va_arg(param, long)) ? TRUE : FALSE; |
818 | 0 | break; |
819 | | |
820 | 0 | case CURLOPT_COOKIELIST: |
821 | 0 | argptr = va_arg(param, char *); |
822 | |
|
823 | 0 | if(!argptr) |
824 | 0 | break; |
825 | | |
826 | 0 | if(strcasecompare(argptr, "ALL")) { |
827 | | /* clear all cookies */ |
828 | 0 | Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); |
829 | 0 | Curl_cookie_clearall(data->cookies); |
830 | 0 | Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); |
831 | 0 | } |
832 | 0 | else if(strcasecompare(argptr, "SESS")) { |
833 | | /* clear session cookies */ |
834 | 0 | Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); |
835 | 0 | Curl_cookie_clearsess(data->cookies); |
836 | 0 | Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); |
837 | 0 | } |
838 | 0 | else if(strcasecompare(argptr, "FLUSH")) { |
839 | | /* flush cookies to file, takes care of the locking */ |
840 | 0 | Curl_flush_cookies(data, FALSE); |
841 | 0 | } |
842 | 0 | else if(strcasecompare(argptr, "RELOAD")) { |
843 | | /* reload cookies from file */ |
844 | 0 | Curl_cookie_loadfiles(data); |
845 | 0 | break; |
846 | 0 | } |
847 | 0 | else { |
848 | 0 | if(!data->cookies) |
849 | | /* if cookie engine was not running, activate it */ |
850 | 0 | data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE); |
851 | | |
852 | | /* general protection against mistakes and abuse */ |
853 | 0 | if(strlen(argptr) > CURL_MAX_INPUT_LENGTH) |
854 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
855 | 0 | argptr = strdup(argptr); |
856 | 0 | if(!argptr || !data->cookies) { |
857 | 0 | result = CURLE_OUT_OF_MEMORY; |
858 | 0 | free(argptr); |
859 | 0 | } |
860 | 0 | else { |
861 | 0 | Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); |
862 | |
|
863 | 0 | if(checkprefix("Set-Cookie:", argptr)) |
864 | | /* HTTP Header format line */ |
865 | 0 | Curl_cookie_add(data, data->cookies, TRUE, FALSE, argptr + 11, NULL, |
866 | 0 | NULL, TRUE); |
867 | | |
868 | 0 | else |
869 | | /* Netscape format line */ |
870 | 0 | Curl_cookie_add(data, data->cookies, FALSE, FALSE, argptr, NULL, |
871 | 0 | NULL, TRUE); |
872 | |
|
873 | 0 | Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); |
874 | 0 | free(argptr); |
875 | 0 | } |
876 | 0 | } |
877 | | |
878 | 0 | break; |
879 | 0 | #endif /* !CURL_DISABLE_COOKIES */ |
880 | | |
881 | 0 | case CURLOPT_HTTPGET: |
882 | | /* |
883 | | * Set to force us do HTTP GET |
884 | | */ |
885 | 0 | if(va_arg(param, long)) { |
886 | 0 | data->set.method = HTTPREQ_GET; |
887 | 0 | data->set.upload = FALSE; /* switch off upload */ |
888 | 0 | data->set.opt_no_body = FALSE; /* this is implied */ |
889 | 0 | } |
890 | 0 | break; |
891 | | |
892 | 49 | case CURLOPT_HTTP_VERSION: |
893 | | /* |
894 | | * This sets a requested HTTP version to be used. The value is one of |
895 | | * the listed enums in curl/curl.h. |
896 | | */ |
897 | 49 | arg = va_arg(param, long); |
898 | 49 | switch(arg) { |
899 | 1 | case CURL_HTTP_VERSION_NONE: |
900 | 1 | #ifdef USE_HTTP2 |
901 | | /* TODO: this seems an undesirable quirk to force a behaviour on |
902 | | * lower implementations that they should recognize independently? */ |
903 | 1 | arg = CURL_HTTP_VERSION_2TLS; |
904 | 1 | #endif |
905 | | /* accepted */ |
906 | 1 | break; |
907 | 0 | case CURL_HTTP_VERSION_1_0: |
908 | 0 | case CURL_HTTP_VERSION_1_1: |
909 | | /* accepted */ |
910 | 0 | break; |
911 | 0 | #ifdef USE_HTTP2 |
912 | 0 | case CURL_HTTP_VERSION_2_0: |
913 | 1 | case CURL_HTTP_VERSION_2TLS: |
914 | 1 | case CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE: |
915 | | /* accepted */ |
916 | 1 | break; |
917 | 0 | #endif |
918 | | #ifdef ENABLE_QUIC |
919 | | case CURL_HTTP_VERSION_3: |
920 | | case CURL_HTTP_VERSION_3ONLY: |
921 | | /* accepted */ |
922 | | break; |
923 | | #endif |
924 | 47 | default: |
925 | | /* not accepted */ |
926 | 47 | if(arg < CURL_HTTP_VERSION_NONE) |
927 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
928 | 47 | return CURLE_UNSUPPORTED_PROTOCOL; |
929 | 49 | } |
930 | 2 | data->set.httpwant = (unsigned char)arg; |
931 | 2 | break; |
932 | | |
933 | 0 | case CURLOPT_EXPECT_100_TIMEOUT_MS: |
934 | | /* |
935 | | * Time to wait for a response to an HTTP request containing an |
936 | | * Expect: 100-continue header before sending the data anyway. |
937 | | */ |
938 | 0 | arg = va_arg(param, long); |
939 | 0 | if(arg < 0) |
940 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
941 | 0 | data->set.expect_100_timeout = arg; |
942 | 0 | break; |
943 | | |
944 | 0 | case CURLOPT_HTTP09_ALLOWED: |
945 | 0 | arg = va_arg(param, unsigned long); |
946 | 0 | if(arg > 1L) |
947 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
948 | | #ifdef USE_HYPER |
949 | | /* Hyper does not support HTTP/0.9 */ |
950 | | if(arg) |
951 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
952 | | #else |
953 | 0 | data->set.http09_allowed = arg ? TRUE : FALSE; |
954 | 0 | #endif |
955 | 0 | break; |
956 | | |
957 | 0 | case CURLOPT_HTTP200ALIASES: |
958 | | /* |
959 | | * Set a list of aliases for HTTP 200 in response header |
960 | | */ |
961 | 0 | data->set.http200aliases = va_arg(param, struct curl_slist *); |
962 | 0 | break; |
963 | 0 | #endif /* CURL_DISABLE_HTTP */ |
964 | | |
965 | 0 | #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ |
966 | 0 | !defined(CURL_DISABLE_IMAP) |
967 | 0 | # if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MIME) |
968 | 0 | case CURLOPT_HTTPHEADER: |
969 | | /* |
970 | | * Set a list with HTTP headers to use (or replace internals with) |
971 | | */ |
972 | 0 | data->set.headers = va_arg(param, struct curl_slist *); |
973 | 0 | break; |
974 | 0 | # endif |
975 | | |
976 | 0 | # ifndef CURL_DISABLE_MIME |
977 | 0 | case CURLOPT_MIMEPOST: |
978 | | /* |
979 | | * Set to make us do MIME POST |
980 | | */ |
981 | 0 | result = Curl_mime_set_subparts(&data->set.mimepost, |
982 | 0 | va_arg(param, curl_mime *), FALSE); |
983 | 0 | if(!result) { |
984 | 0 | data->set.method = HTTPREQ_POST_MIME; |
985 | 0 | data->set.opt_no_body = FALSE; /* this is implied */ |
986 | 0 | } |
987 | 0 | break; |
988 | | |
989 | 0 | case CURLOPT_MIME_OPTIONS: |
990 | 0 | data->set.mime_options = (unsigned int)va_arg(param, long); |
991 | 0 | break; |
992 | 0 | # endif |
993 | 0 | #endif |
994 | | |
995 | 37 | case CURLOPT_HTTPAUTH: |
996 | | /* |
997 | | * Set HTTP Authentication type BITMASK. |
998 | | */ |
999 | 37 | { |
1000 | 37 | int bitcheck; |
1001 | 37 | bool authbits; |
1002 | 37 | unsigned long auth = va_arg(param, unsigned long); |
1003 | | |
1004 | 37 | if(auth == CURLAUTH_NONE) { |
1005 | 2 | data->set.httpauth = auth; |
1006 | 2 | break; |
1007 | 2 | } |
1008 | | |
1009 | | /* the DIGEST_IE bit is only used to set a special marker, for all the |
1010 | | rest we need to handle it as normal DIGEST */ |
1011 | 35 | data->state.authhost.iestyle = |
1012 | 35 | (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE); |
1013 | | |
1014 | 35 | if(auth & CURLAUTH_DIGEST_IE) { |
1015 | 15 | auth |= CURLAUTH_DIGEST; /* set standard digest bit */ |
1016 | 15 | auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */ |
1017 | 15 | } |
1018 | | |
1019 | | /* switch off bits we can't support */ |
1020 | 35 | #ifndef USE_NTLM |
1021 | 35 | auth &= ~CURLAUTH_NTLM; /* no NTLM support */ |
1022 | 35 | auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ |
1023 | | #elif !defined(NTLM_WB_ENABLED) |
1024 | | auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ |
1025 | | #endif |
1026 | 35 | #ifndef USE_SPNEGO |
1027 | 35 | auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without |
1028 | | GSS-API or SSPI */ |
1029 | 35 | #endif |
1030 | | |
1031 | | /* check if any auth bit lower than CURLAUTH_ONLY is still set */ |
1032 | 35 | bitcheck = 0; |
1033 | 35 | authbits = FALSE; |
1034 | 322 | while(bitcheck < 31) { |
1035 | 320 | if(auth & (1UL << bitcheck++)) { |
1036 | 33 | authbits = TRUE; |
1037 | 33 | break; |
1038 | 33 | } |
1039 | 320 | } |
1040 | 35 | if(!authbits) |
1041 | 2 | return CURLE_NOT_BUILT_IN; /* no supported types left! */ |
1042 | | |
1043 | 33 | data->set.httpauth = auth; |
1044 | 33 | } |
1045 | 0 | break; |
1046 | | |
1047 | 4 | case CURLOPT_CUSTOMREQUEST: |
1048 | | /* |
1049 | | * Set a custom string to use as request |
1050 | | */ |
1051 | 4 | result = Curl_setstropt(&data->set.str[STRING_CUSTOMREQUEST], |
1052 | 4 | va_arg(param, char *)); |
1053 | | |
1054 | | /* we don't set |
1055 | | data->set.method = HTTPREQ_CUSTOM; |
1056 | | here, we continue as if we were using the already set type |
1057 | | and this just changes the actual request keyword */ |
1058 | 4 | break; |
1059 | | |
1060 | 0 | #ifndef CURL_DISABLE_PROXY |
1061 | 0 | case CURLOPT_HTTPPROXYTUNNEL: |
1062 | | /* |
1063 | | * Tunnel operations through the proxy instead of normal proxy use |
1064 | | */ |
1065 | 0 | data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long)) ? |
1066 | 0 | TRUE : FALSE; |
1067 | 0 | break; |
1068 | | |
1069 | 0 | case CURLOPT_PROXYPORT: |
1070 | | /* |
1071 | | * Explicitly set HTTP proxy port number. |
1072 | | */ |
1073 | 0 | arg = va_arg(param, long); |
1074 | 0 | if((arg < 0) || (arg > 65535)) |
1075 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1076 | 0 | data->set.proxyport = (unsigned short)arg; |
1077 | 0 | break; |
1078 | | |
1079 | 0 | case CURLOPT_PROXYAUTH: |
1080 | | /* |
1081 | | * Set HTTP Authentication type BITMASK. |
1082 | | */ |
1083 | 0 | { |
1084 | 0 | int bitcheck; |
1085 | 0 | bool authbits; |
1086 | 0 | unsigned long auth = va_arg(param, unsigned long); |
1087 | |
|
1088 | 0 | if(auth == CURLAUTH_NONE) { |
1089 | 0 | data->set.proxyauth = auth; |
1090 | 0 | break; |
1091 | 0 | } |
1092 | | |
1093 | | /* the DIGEST_IE bit is only used to set a special marker, for all the |
1094 | | rest we need to handle it as normal DIGEST */ |
1095 | 0 | data->state.authproxy.iestyle = |
1096 | 0 | (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE); |
1097 | |
|
1098 | 0 | if(auth & CURLAUTH_DIGEST_IE) { |
1099 | 0 | auth |= CURLAUTH_DIGEST; /* set standard digest bit */ |
1100 | 0 | auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */ |
1101 | 0 | } |
1102 | | /* switch off bits we can't support */ |
1103 | 0 | #ifndef USE_NTLM |
1104 | 0 | auth &= ~CURLAUTH_NTLM; /* no NTLM support */ |
1105 | 0 | auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ |
1106 | | #elif !defined(NTLM_WB_ENABLED) |
1107 | | auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ |
1108 | | #endif |
1109 | 0 | #ifndef USE_SPNEGO |
1110 | 0 | auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without |
1111 | | GSS-API or SSPI */ |
1112 | 0 | #endif |
1113 | | |
1114 | | /* check if any auth bit lower than CURLAUTH_ONLY is still set */ |
1115 | 0 | bitcheck = 0; |
1116 | 0 | authbits = FALSE; |
1117 | 0 | while(bitcheck < 31) { |
1118 | 0 | if(auth & (1UL << bitcheck++)) { |
1119 | 0 | authbits = TRUE; |
1120 | 0 | break; |
1121 | 0 | } |
1122 | 0 | } |
1123 | 0 | if(!authbits) |
1124 | 0 | return CURLE_NOT_BUILT_IN; /* no supported types left! */ |
1125 | | |
1126 | 0 | data->set.proxyauth = auth; |
1127 | 0 | } |
1128 | 0 | break; |
1129 | | |
1130 | 0 | case CURLOPT_PROXY: |
1131 | | /* |
1132 | | * Set proxy server:port to use as proxy. |
1133 | | * |
1134 | | * If the proxy is set to "" (and CURLOPT_SOCKS_PROXY is set to "" or NULL) |
1135 | | * we explicitly say that we don't want to use a proxy |
1136 | | * (even though there might be environment variables saying so). |
1137 | | * |
1138 | | * Setting it to NULL, means no proxy but allows the environment variables |
1139 | | * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL). |
1140 | | */ |
1141 | 0 | result = Curl_setstropt(&data->set.str[STRING_PROXY], |
1142 | 0 | va_arg(param, char *)); |
1143 | 0 | break; |
1144 | | |
1145 | 0 | case CURLOPT_PRE_PROXY: |
1146 | | /* |
1147 | | * Set proxy server:port to use as SOCKS proxy. |
1148 | | * |
1149 | | * If the proxy is set to "" or NULL we explicitly say that we don't want |
1150 | | * to use the socks proxy. |
1151 | | */ |
1152 | 0 | result = Curl_setstropt(&data->set.str[STRING_PRE_PROXY], |
1153 | 0 | va_arg(param, char *)); |
1154 | 0 | break; |
1155 | | |
1156 | 0 | case CURLOPT_PROXYTYPE: |
1157 | | /* |
1158 | | * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME |
1159 | | */ |
1160 | 0 | arg = va_arg(param, long); |
1161 | 0 | if((arg < CURLPROXY_HTTP) || (arg > CURLPROXY_SOCKS5_HOSTNAME)) |
1162 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1163 | 0 | data->set.proxytype = (unsigned char)(curl_proxytype)arg; |
1164 | 0 | break; |
1165 | | |
1166 | 0 | case CURLOPT_PROXY_TRANSFER_MODE: |
1167 | | /* |
1168 | | * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy |
1169 | | */ |
1170 | 0 | switch(va_arg(param, long)) { |
1171 | 0 | case 0: |
1172 | 0 | data->set.proxy_transfer_mode = FALSE; |
1173 | 0 | break; |
1174 | 0 | case 1: |
1175 | 0 | data->set.proxy_transfer_mode = TRUE; |
1176 | 0 | break; |
1177 | 0 | default: |
1178 | | /* reserve other values for future use */ |
1179 | 0 | result = CURLE_BAD_FUNCTION_ARGUMENT; |
1180 | 0 | break; |
1181 | 0 | } |
1182 | 0 | break; |
1183 | | |
1184 | 0 | case CURLOPT_SOCKS5_AUTH: |
1185 | 0 | data->set.socks5auth = (unsigned char)va_arg(param, unsigned long); |
1186 | 0 | if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI)) |
1187 | 0 | result = CURLE_NOT_BUILT_IN; |
1188 | 0 | break; |
1189 | 0 | #endif /* CURL_DISABLE_PROXY */ |
1190 | | |
1191 | | #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) |
1192 | | case CURLOPT_SOCKS5_GSSAPI_NEC: |
1193 | | /* |
1194 | | * Set flag for NEC SOCK5 support |
1195 | | */ |
1196 | | data->set.socks5_gssapi_nec = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1197 | | break; |
1198 | | #endif |
1199 | 0 | #ifndef CURL_DISABLE_PROXY |
1200 | 0 | case CURLOPT_SOCKS5_GSSAPI_SERVICE: |
1201 | 0 | case CURLOPT_PROXY_SERVICE_NAME: |
1202 | | /* |
1203 | | * Set proxy authentication service name for Kerberos 5 and SPNEGO |
1204 | | */ |
1205 | 0 | result = Curl_setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME], |
1206 | 0 | va_arg(param, char *)); |
1207 | 0 | break; |
1208 | 0 | #endif |
1209 | 0 | case CURLOPT_SERVICE_NAME: |
1210 | | /* |
1211 | | * Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO |
1212 | | */ |
1213 | 0 | result = Curl_setstropt(&data->set.str[STRING_SERVICE_NAME], |
1214 | 0 | va_arg(param, char *)); |
1215 | 0 | break; |
1216 | | |
1217 | 0 | case CURLOPT_HEADERDATA: |
1218 | | /* |
1219 | | * Custom pointer to pass the header write callback function |
1220 | | */ |
1221 | 0 | data->set.writeheader = (void *)va_arg(param, void *); |
1222 | 0 | break; |
1223 | 0 | case CURLOPT_ERRORBUFFER: |
1224 | | /* |
1225 | | * Error buffer provided by the caller to get the human readable |
1226 | | * error string in. |
1227 | | */ |
1228 | 0 | data->set.errorbuffer = va_arg(param, char *); |
1229 | 0 | break; |
1230 | 690 | case CURLOPT_WRITEDATA: |
1231 | | /* |
1232 | | * FILE pointer to write to. Or possibly |
1233 | | * used as argument to the write callback. |
1234 | | */ |
1235 | 690 | data->set.out = va_arg(param, void *); |
1236 | 690 | break; |
1237 | | |
1238 | 0 | case CURLOPT_DIRLISTONLY: |
1239 | | /* |
1240 | | * An option that changes the command to one that asks for a list only, no |
1241 | | * file info details. Used for FTP, POP3 and SFTP. |
1242 | | */ |
1243 | 0 | data->set.list_only = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1244 | 0 | break; |
1245 | | |
1246 | 0 | case CURLOPT_APPEND: |
1247 | | /* |
1248 | | * We want to upload and append to an existing file. Used for FTP and |
1249 | | * SFTP. |
1250 | | */ |
1251 | 0 | data->set.remote_append = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1252 | 0 | break; |
1253 | | |
1254 | 0 | #ifndef CURL_DISABLE_FTP |
1255 | 0 | case CURLOPT_FTP_FILEMETHOD: |
1256 | | /* |
1257 | | * How do access files over FTP. |
1258 | | */ |
1259 | 0 | arg = va_arg(param, long); |
1260 | 0 | if((arg < CURLFTPMETHOD_DEFAULT) || (arg >= CURLFTPMETHOD_LAST)) |
1261 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1262 | 0 | data->set.ftp_filemethod = (unsigned char)(curl_ftpfile)arg; |
1263 | 0 | break; |
1264 | 0 | case CURLOPT_FTPPORT: |
1265 | | /* |
1266 | | * Use FTP PORT, this also specifies which IP address to use |
1267 | | */ |
1268 | 0 | result = Curl_setstropt(&data->set.str[STRING_FTPPORT], |
1269 | 0 | va_arg(param, char *)); |
1270 | 0 | data->set.ftp_use_port = (data->set.str[STRING_FTPPORT]) ? TRUE : FALSE; |
1271 | 0 | break; |
1272 | | |
1273 | 0 | case CURLOPT_FTP_USE_EPRT: |
1274 | 0 | data->set.ftp_use_eprt = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1275 | 0 | break; |
1276 | | |
1277 | 0 | case CURLOPT_FTP_USE_EPSV: |
1278 | 0 | data->set.ftp_use_epsv = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1279 | 0 | break; |
1280 | | |
1281 | 0 | case CURLOPT_FTP_USE_PRET: |
1282 | 0 | data->set.ftp_use_pret = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1283 | 0 | break; |
1284 | | |
1285 | 0 | case CURLOPT_FTP_SSL_CCC: |
1286 | 0 | arg = va_arg(param, long); |
1287 | 0 | if((arg < CURLFTPSSL_CCC_NONE) || (arg >= CURLFTPSSL_CCC_LAST)) |
1288 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1289 | 0 | data->set.ftp_ccc = (unsigned char)(curl_ftpccc)arg; |
1290 | 0 | break; |
1291 | | |
1292 | 0 | case CURLOPT_FTP_SKIP_PASV_IP: |
1293 | | /* |
1294 | | * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the |
1295 | | * bypass of the IP address in PASV responses. |
1296 | | */ |
1297 | 0 | data->set.ftp_skip_ip = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1298 | 0 | break; |
1299 | | |
1300 | 0 | case CURLOPT_FTP_ACCOUNT: |
1301 | 0 | result = Curl_setstropt(&data->set.str[STRING_FTP_ACCOUNT], |
1302 | 0 | va_arg(param, char *)); |
1303 | 0 | break; |
1304 | | |
1305 | 0 | case CURLOPT_FTP_ALTERNATIVE_TO_USER: |
1306 | 0 | result = Curl_setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER], |
1307 | 0 | va_arg(param, char *)); |
1308 | 0 | break; |
1309 | | |
1310 | 0 | case CURLOPT_FTPSSLAUTH: |
1311 | | /* |
1312 | | * Set a specific auth for FTP-SSL transfers. |
1313 | | */ |
1314 | 0 | arg = va_arg(param, long); |
1315 | 0 | if((arg < CURLFTPAUTH_DEFAULT) || (arg >= CURLFTPAUTH_LAST)) |
1316 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1317 | 0 | data->set.ftpsslauth = (unsigned char)(curl_ftpauth)arg; |
1318 | 0 | break; |
1319 | 0 | case CURLOPT_KRBLEVEL: |
1320 | | /* |
1321 | | * A string that defines the kerberos security level. |
1322 | | */ |
1323 | 0 | result = Curl_setstropt(&data->set.str[STRING_KRB_LEVEL], |
1324 | 0 | va_arg(param, char *)); |
1325 | 0 | data->set.krb = (data->set.str[STRING_KRB_LEVEL]) ? TRUE : FALSE; |
1326 | 0 | break; |
1327 | 0 | #endif |
1328 | 0 | #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) |
1329 | 0 | case CURLOPT_FTP_CREATE_MISSING_DIRS: |
1330 | | /* |
1331 | | * An FTP/SFTP option that modifies an upload to create missing |
1332 | | * directories on the server. |
1333 | | */ |
1334 | 0 | arg = va_arg(param, long); |
1335 | | /* reserve other values for future use */ |
1336 | 0 | if((arg < CURLFTP_CREATE_DIR_NONE) || |
1337 | 0 | (arg > CURLFTP_CREATE_DIR_RETRY)) |
1338 | 0 | result = CURLE_BAD_FUNCTION_ARGUMENT; |
1339 | 0 | else |
1340 | 0 | data->set.ftp_create_missing_dirs = (unsigned char)arg; |
1341 | 0 | break; |
1342 | | |
1343 | 0 | case CURLOPT_POSTQUOTE: |
1344 | | /* |
1345 | | * List of RAW FTP commands to use after a transfer |
1346 | | */ |
1347 | 0 | data->set.postquote = va_arg(param, struct curl_slist *); |
1348 | 0 | break; |
1349 | 0 | case CURLOPT_PREQUOTE: |
1350 | | /* |
1351 | | * List of RAW FTP commands to use prior to RETR (Wesley Laxton) |
1352 | | */ |
1353 | 0 | data->set.prequote = va_arg(param, struct curl_slist *); |
1354 | 0 | break; |
1355 | 0 | case CURLOPT_QUOTE: |
1356 | | /* |
1357 | | * List of RAW FTP commands to use before a transfer |
1358 | | */ |
1359 | 0 | data->set.quote = va_arg(param, struct curl_slist *); |
1360 | 0 | break; |
1361 | 0 | #endif |
1362 | 690 | case CURLOPT_READDATA: |
1363 | | /* |
1364 | | * FILE pointer to read the file to be uploaded from. Or possibly |
1365 | | * used as argument to the read callback. |
1366 | | */ |
1367 | 690 | data->set.in_set = va_arg(param, void *); |
1368 | 690 | break; |
1369 | 0 | case CURLOPT_INFILESIZE: |
1370 | | /* |
1371 | | * If known, this should inform curl about the file size of the |
1372 | | * to-be-uploaded file. |
1373 | | */ |
1374 | 0 | arg = va_arg(param, long); |
1375 | 0 | if(arg < -1) |
1376 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1377 | 0 | data->set.filesize = arg; |
1378 | 0 | break; |
1379 | 30 | case CURLOPT_INFILESIZE_LARGE: |
1380 | | /* |
1381 | | * If known, this should inform curl about the file size of the |
1382 | | * to-be-uploaded file. |
1383 | | */ |
1384 | 30 | bigsize = va_arg(param, curl_off_t); |
1385 | 30 | if(bigsize < -1) |
1386 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1387 | 30 | data->set.filesize = bigsize; |
1388 | 30 | break; |
1389 | 0 | case CURLOPT_LOW_SPEED_LIMIT: |
1390 | | /* |
1391 | | * The low speed limit that if transfers are below this for |
1392 | | * CURLOPT_LOW_SPEED_TIME, the transfer is aborted. |
1393 | | */ |
1394 | 0 | arg = va_arg(param, long); |
1395 | 0 | if(arg < 0) |
1396 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1397 | 0 | data->set.low_speed_limit = arg; |
1398 | 0 | break; |
1399 | 0 | case CURLOPT_MAX_SEND_SPEED_LARGE: |
1400 | | /* |
1401 | | * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE |
1402 | | * bytes per second the transfer is throttled.. |
1403 | | */ |
1404 | 0 | bigsize = va_arg(param, curl_off_t); |
1405 | 0 | if(bigsize < 0) |
1406 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1407 | 0 | data->set.max_send_speed = bigsize; |
1408 | 0 | break; |
1409 | 0 | case CURLOPT_MAX_RECV_SPEED_LARGE: |
1410 | | /* |
1411 | | * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per |
1412 | | * second the transfer is throttled.. |
1413 | | */ |
1414 | 0 | bigsize = va_arg(param, curl_off_t); |
1415 | 0 | if(bigsize < 0) |
1416 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1417 | 0 | data->set.max_recv_speed = bigsize; |
1418 | 0 | break; |
1419 | 0 | case CURLOPT_LOW_SPEED_TIME: |
1420 | | /* |
1421 | | * The low speed time that if transfers are below the set |
1422 | | * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted. |
1423 | | */ |
1424 | 0 | arg = va_arg(param, long); |
1425 | 0 | if(arg < 0) |
1426 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1427 | 0 | data->set.low_speed_time = arg; |
1428 | 0 | break; |
1429 | 0 | case CURLOPT_CURLU: |
1430 | | /* |
1431 | | * pass CURLU to set URL |
1432 | | */ |
1433 | 0 | data->set.uh = va_arg(param, CURLU *); |
1434 | 0 | break; |
1435 | 57 | case CURLOPT_URL: |
1436 | | /* |
1437 | | * The URL to fetch. |
1438 | | */ |
1439 | 57 | if(data->state.url_alloc) { |
1440 | | /* the already set URL is allocated, free it first! */ |
1441 | 0 | Curl_safefree(data->state.url); |
1442 | 0 | data->state.url_alloc = FALSE; |
1443 | 0 | } |
1444 | 57 | result = Curl_setstropt(&data->set.str[STRING_SET_URL], |
1445 | 57 | va_arg(param, char *)); |
1446 | 57 | data->state.url = data->set.str[STRING_SET_URL]; |
1447 | 57 | break; |
1448 | 0 | case CURLOPT_PORT: |
1449 | | /* |
1450 | | * The port number to use when getting the URL. 0 disables it. |
1451 | | */ |
1452 | 0 | arg = va_arg(param, long); |
1453 | 0 | if((arg < 0) || (arg > 65535)) |
1454 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1455 | 0 | data->set.use_port = (unsigned short)arg; |
1456 | 0 | break; |
1457 | 0 | case CURLOPT_TIMEOUT: |
1458 | | /* |
1459 | | * The maximum time you allow curl to use for a single transfer |
1460 | | * operation. |
1461 | | */ |
1462 | 0 | arg = va_arg(param, long); |
1463 | 0 | if((arg >= 0) && (arg <= (INT_MAX/1000))) |
1464 | 0 | data->set.timeout = (unsigned int)arg * 1000; |
1465 | 0 | else |
1466 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1467 | 0 | break; |
1468 | | |
1469 | 0 | case CURLOPT_TIMEOUT_MS: |
1470 | 0 | uarg = va_arg(param, unsigned long); |
1471 | 0 | if(uarg > UINT_MAX) |
1472 | 0 | uarg = UINT_MAX; |
1473 | 0 | data->set.timeout = (unsigned int)uarg; |
1474 | 0 | break; |
1475 | | |
1476 | 0 | case CURLOPT_CONNECTTIMEOUT: |
1477 | | /* |
1478 | | * The maximum time you allow curl to use to connect. |
1479 | | */ |
1480 | 0 | arg = va_arg(param, long); |
1481 | 0 | if((arg >= 0) && (arg <= (INT_MAX/1000))) |
1482 | 0 | data->set.connecttimeout = (unsigned int)arg * 1000; |
1483 | 0 | else |
1484 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1485 | 0 | break; |
1486 | | |
1487 | 0 | case CURLOPT_CONNECTTIMEOUT_MS: |
1488 | 0 | uarg = va_arg(param, unsigned long); |
1489 | 0 | if(uarg > UINT_MAX) |
1490 | 0 | uarg = UINT_MAX; |
1491 | 0 | data->set.connecttimeout = (unsigned int)uarg; |
1492 | 0 | break; |
1493 | | |
1494 | 0 | #ifndef CURL_DISABLE_FTP |
1495 | 0 | case CURLOPT_ACCEPTTIMEOUT_MS: |
1496 | | /* |
1497 | | * The maximum time for curl to wait for FTP server connect |
1498 | | */ |
1499 | 0 | uarg = va_arg(param, unsigned long); |
1500 | 0 | if(uarg > UINT_MAX) |
1501 | 0 | uarg = UINT_MAX; |
1502 | 0 | data->set.accepttimeout = (unsigned int)uarg; |
1503 | 0 | break; |
1504 | 0 | #endif |
1505 | | |
1506 | 41 | case CURLOPT_USERPWD: |
1507 | | /* |
1508 | | * user:password to use in the operation |
1509 | | */ |
1510 | 41 | result = setstropt_userpwd(va_arg(param, char *), |
1511 | 41 | &data->set.str[STRING_USERNAME], |
1512 | 41 | &data->set.str[STRING_PASSWORD]); |
1513 | 41 | break; |
1514 | | |
1515 | 7 | case CURLOPT_USERNAME: |
1516 | | /* |
1517 | | * authentication user name to use in the operation |
1518 | | */ |
1519 | 7 | result = Curl_setstropt(&data->set.str[STRING_USERNAME], |
1520 | 7 | va_arg(param, char *)); |
1521 | 7 | break; |
1522 | 7 | case CURLOPT_PASSWORD: |
1523 | | /* |
1524 | | * authentication password to use in the operation |
1525 | | */ |
1526 | 7 | result = Curl_setstropt(&data->set.str[STRING_PASSWORD], |
1527 | 7 | va_arg(param, char *)); |
1528 | 7 | break; |
1529 | | |
1530 | 3 | case CURLOPT_LOGIN_OPTIONS: |
1531 | | /* |
1532 | | * authentication options to use in the operation |
1533 | | */ |
1534 | 3 | result = Curl_setstropt(&data->set.str[STRING_OPTIONS], |
1535 | 3 | va_arg(param, char *)); |
1536 | 3 | break; |
1537 | | |
1538 | 10 | case CURLOPT_XOAUTH2_BEARER: |
1539 | | /* |
1540 | | * OAuth 2.0 bearer token to use in the operation |
1541 | | */ |
1542 | 10 | result = Curl_setstropt(&data->set.str[STRING_BEARER], |
1543 | 10 | va_arg(param, char *)); |
1544 | 10 | break; |
1545 | | |
1546 | 0 | case CURLOPT_RESOLVE: |
1547 | | /* |
1548 | | * List of HOST:PORT:[addresses] strings to populate the DNS cache with |
1549 | | * Entries added this way will remain in the cache until explicitly |
1550 | | * removed or the handle is cleaned up. |
1551 | | * |
1552 | | * Prefix the HOST with plus sign (+) to have the entry expire just like |
1553 | | * automatically added entries. |
1554 | | * |
1555 | | * Prefix the HOST with dash (-) to _remove_ the entry from the cache. |
1556 | | * |
1557 | | * This API can remove any entry from the DNS cache, but only entries |
1558 | | * that aren't actually in use right now will be pruned immediately. |
1559 | | */ |
1560 | 0 | data->set.resolve = va_arg(param, struct curl_slist *); |
1561 | 0 | data->state.resolve = data->set.resolve; |
1562 | 0 | break; |
1563 | 0 | case CURLOPT_PROGRESSFUNCTION: |
1564 | | /* |
1565 | | * Progress callback function |
1566 | | */ |
1567 | 0 | data->set.fprogress = va_arg(param, curl_progress_callback); |
1568 | 0 | if(data->set.fprogress) |
1569 | 0 | data->progress.callback = TRUE; /* no longer internal */ |
1570 | 0 | else |
1571 | 0 | data->progress.callback = FALSE; /* NULL enforces internal */ |
1572 | 0 | break; |
1573 | | |
1574 | 0 | case CURLOPT_XFERINFOFUNCTION: |
1575 | | /* |
1576 | | * Transfer info callback function |
1577 | | */ |
1578 | 0 | data->set.fxferinfo = va_arg(param, curl_xferinfo_callback); |
1579 | 0 | if(data->set.fxferinfo) |
1580 | 0 | data->progress.callback = TRUE; /* no longer internal */ |
1581 | 0 | else |
1582 | 0 | data->progress.callback = FALSE; /* NULL enforces internal */ |
1583 | |
|
1584 | 0 | break; |
1585 | | |
1586 | 0 | case CURLOPT_PROGRESSDATA: |
1587 | | /* |
1588 | | * Custom client data to pass to the progress callback |
1589 | | */ |
1590 | 0 | data->set.progress_client = va_arg(param, void *); |
1591 | 0 | break; |
1592 | | |
1593 | 0 | #ifndef CURL_DISABLE_PROXY |
1594 | 0 | case CURLOPT_PROXYUSERPWD: |
1595 | | /* |
1596 | | * user:password needed to use the proxy |
1597 | | */ |
1598 | 0 | result = setstropt_userpwd(va_arg(param, char *), |
1599 | 0 | &data->set.str[STRING_PROXYUSERNAME], |
1600 | 0 | &data->set.str[STRING_PROXYPASSWORD]); |
1601 | 0 | break; |
1602 | 0 | case CURLOPT_PROXYUSERNAME: |
1603 | | /* |
1604 | | * authentication user name to use in the operation |
1605 | | */ |
1606 | 0 | result = Curl_setstropt(&data->set.str[STRING_PROXYUSERNAME], |
1607 | 0 | va_arg(param, char *)); |
1608 | 0 | break; |
1609 | 0 | case CURLOPT_PROXYPASSWORD: |
1610 | | /* |
1611 | | * authentication password to use in the operation |
1612 | | */ |
1613 | 0 | result = Curl_setstropt(&data->set.str[STRING_PROXYPASSWORD], |
1614 | 0 | va_arg(param, char *)); |
1615 | 0 | break; |
1616 | 0 | case CURLOPT_NOPROXY: |
1617 | | /* |
1618 | | * proxy exception list |
1619 | | */ |
1620 | 0 | result = Curl_setstropt(&data->set.str[STRING_NOPROXY], |
1621 | 0 | va_arg(param, char *)); |
1622 | 0 | break; |
1623 | 0 | #endif |
1624 | | |
1625 | 8 | case CURLOPT_RANGE: |
1626 | | /* |
1627 | | * What range of the file you want to transfer |
1628 | | */ |
1629 | 8 | result = Curl_setstropt(&data->set.str[STRING_SET_RANGE], |
1630 | 8 | va_arg(param, char *)); |
1631 | 8 | break; |
1632 | 0 | case CURLOPT_RESUME_FROM: |
1633 | | /* |
1634 | | * Resume transfer at the given file position |
1635 | | */ |
1636 | 0 | arg = va_arg(param, long); |
1637 | 0 | if(arg < -1) |
1638 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1639 | 0 | data->set.set_resume_from = arg; |
1640 | 0 | break; |
1641 | 0 | case CURLOPT_RESUME_FROM_LARGE: |
1642 | | /* |
1643 | | * Resume transfer at the given file position |
1644 | | */ |
1645 | 0 | bigsize = va_arg(param, curl_off_t); |
1646 | 0 | if(bigsize < -1) |
1647 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1648 | 0 | data->set.set_resume_from = bigsize; |
1649 | 0 | break; |
1650 | 0 | case CURLOPT_DEBUGFUNCTION: |
1651 | | /* |
1652 | | * stderr write callback. |
1653 | | */ |
1654 | 0 | data->set.fdebug = va_arg(param, curl_debug_callback); |
1655 | | /* |
1656 | | * if the callback provided is NULL, it'll use the default callback |
1657 | | */ |
1658 | 0 | break; |
1659 | 0 | case CURLOPT_DEBUGDATA: |
1660 | | /* |
1661 | | * Set to a void * that should receive all error writes. This |
1662 | | * defaults to CURLOPT_STDERR for normal operations. |
1663 | | */ |
1664 | 0 | data->set.debugdata = va_arg(param, void *); |
1665 | 0 | break; |
1666 | 0 | case CURLOPT_STDERR: |
1667 | | /* |
1668 | | * Set to a FILE * that should receive all error writes. This |
1669 | | * defaults to stderr for normal operations. |
1670 | | */ |
1671 | 0 | data->set.err = va_arg(param, FILE *); |
1672 | 0 | if(!data->set.err) |
1673 | 0 | data->set.err = stderr; |
1674 | 0 | break; |
1675 | 0 | case CURLOPT_HEADERFUNCTION: |
1676 | | /* |
1677 | | * Set header write callback |
1678 | | */ |
1679 | 0 | data->set.fwrite_header = va_arg(param, curl_write_callback); |
1680 | 0 | break; |
1681 | 690 | case CURLOPT_WRITEFUNCTION: |
1682 | | /* |
1683 | | * Set data write callback |
1684 | | */ |
1685 | 690 | data->set.fwrite_func = va_arg(param, curl_write_callback); |
1686 | 690 | if(!data->set.fwrite_func) |
1687 | | /* When set to NULL, reset to our internal default function */ |
1688 | 0 | data->set.fwrite_func = (curl_write_callback)fwrite; |
1689 | 690 | break; |
1690 | 690 | case CURLOPT_READFUNCTION: |
1691 | | /* |
1692 | | * Read data callback |
1693 | | */ |
1694 | 690 | data->set.fread_func_set = va_arg(param, curl_read_callback); |
1695 | 690 | if(!data->set.fread_func_set) { |
1696 | 0 | data->set.is_fread_set = 0; |
1697 | | /* When set to NULL, reset to our internal default function */ |
1698 | 0 | data->set.fread_func_set = (curl_read_callback)fread; |
1699 | 0 | } |
1700 | 690 | else |
1701 | 690 | data->set.is_fread_set = 1; |
1702 | 690 | break; |
1703 | 0 | case CURLOPT_SEEKFUNCTION: |
1704 | | /* |
1705 | | * Seek callback. Might be NULL. |
1706 | | */ |
1707 | 0 | data->set.seek_func = va_arg(param, curl_seek_callback); |
1708 | 0 | break; |
1709 | 0 | case CURLOPT_SEEKDATA: |
1710 | | /* |
1711 | | * Seek control callback. Might be NULL. |
1712 | | */ |
1713 | 0 | data->set.seek_client = va_arg(param, void *); |
1714 | 0 | break; |
1715 | 0 | case CURLOPT_IOCTLFUNCTION: |
1716 | | /* |
1717 | | * I/O control callback. Might be NULL. |
1718 | | */ |
1719 | 0 | data->set.ioctl_func = va_arg(param, curl_ioctl_callback); |
1720 | 0 | break; |
1721 | 0 | case CURLOPT_IOCTLDATA: |
1722 | | /* |
1723 | | * I/O control data pointer. Might be NULL. |
1724 | | */ |
1725 | 0 | data->set.ioctl_client = va_arg(param, void *); |
1726 | 0 | break; |
1727 | 0 | case CURLOPT_SSLCERT: |
1728 | | /* |
1729 | | * String that holds file name of the SSL certificate to use |
1730 | | */ |
1731 | 0 | result = Curl_setstropt(&data->set.str[STRING_CERT], |
1732 | 0 | va_arg(param, char *)); |
1733 | 0 | break; |
1734 | 0 | case CURLOPT_SSLCERT_BLOB: |
1735 | | /* |
1736 | | * Blob that holds file content of the SSL certificate to use |
1737 | | */ |
1738 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_CERT], |
1739 | 0 | va_arg(param, struct curl_blob *)); |
1740 | 0 | break; |
1741 | 0 | #ifndef CURL_DISABLE_PROXY |
1742 | 0 | case CURLOPT_PROXY_SSLCERT: |
1743 | | /* |
1744 | | * String that holds file name of the SSL certificate to use for proxy |
1745 | | */ |
1746 | 0 | result = Curl_setstropt(&data->set.str[STRING_CERT_PROXY], |
1747 | 0 | va_arg(param, char *)); |
1748 | 0 | break; |
1749 | 0 | case CURLOPT_PROXY_SSLCERT_BLOB: |
1750 | | /* |
1751 | | * Blob that holds file content of the SSL certificate to use for proxy |
1752 | | */ |
1753 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_PROXY], |
1754 | 0 | va_arg(param, struct curl_blob *)); |
1755 | 0 | break; |
1756 | 0 | #endif |
1757 | 0 | case CURLOPT_SSLCERTTYPE: |
1758 | | /* |
1759 | | * String that holds file type of the SSL certificate to use |
1760 | | */ |
1761 | 0 | result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE], |
1762 | 0 | va_arg(param, char *)); |
1763 | 0 | break; |
1764 | 0 | #ifndef CURL_DISABLE_PROXY |
1765 | 0 | case CURLOPT_PROXY_SSLCERTTYPE: |
1766 | | /* |
1767 | | * String that holds file type of the SSL certificate to use for proxy |
1768 | | */ |
1769 | 0 | result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_PROXY], |
1770 | 0 | va_arg(param, char *)); |
1771 | 0 | break; |
1772 | 0 | #endif |
1773 | 0 | case CURLOPT_SSLKEY: |
1774 | | /* |
1775 | | * String that holds file name of the SSL key to use |
1776 | | */ |
1777 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY], |
1778 | 0 | va_arg(param, char *)); |
1779 | 0 | break; |
1780 | 0 | case CURLOPT_SSLKEY_BLOB: |
1781 | | /* |
1782 | | * Blob that holds file content of the SSL key to use |
1783 | | */ |
1784 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_KEY], |
1785 | 0 | va_arg(param, struct curl_blob *)); |
1786 | 0 | break; |
1787 | 0 | #ifndef CURL_DISABLE_PROXY |
1788 | 0 | case CURLOPT_PROXY_SSLKEY: |
1789 | | /* |
1790 | | * String that holds file name of the SSL key to use for proxy |
1791 | | */ |
1792 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY_PROXY], |
1793 | 0 | va_arg(param, char *)); |
1794 | 0 | break; |
1795 | 0 | case CURLOPT_PROXY_SSLKEY_BLOB: |
1796 | | /* |
1797 | | * Blob that holds file content of the SSL key to use for proxy |
1798 | | */ |
1799 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_PROXY], |
1800 | 0 | va_arg(param, struct curl_blob *)); |
1801 | 0 | break; |
1802 | 0 | #endif |
1803 | 0 | case CURLOPT_SSLKEYTYPE: |
1804 | | /* |
1805 | | * String that holds file type of the SSL key to use |
1806 | | */ |
1807 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE], |
1808 | 0 | va_arg(param, char *)); |
1809 | 0 | break; |
1810 | 0 | #ifndef CURL_DISABLE_PROXY |
1811 | 0 | case CURLOPT_PROXY_SSLKEYTYPE: |
1812 | | /* |
1813 | | * String that holds file type of the SSL key to use for proxy |
1814 | | */ |
1815 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_PROXY], |
1816 | 0 | va_arg(param, char *)); |
1817 | 0 | break; |
1818 | 0 | #endif |
1819 | 0 | case CURLOPT_KEYPASSWD: |
1820 | | /* |
1821 | | * String that holds the SSL or SSH private key password. |
1822 | | */ |
1823 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD], |
1824 | 0 | va_arg(param, char *)); |
1825 | 0 | break; |
1826 | 0 | #ifndef CURL_DISABLE_PROXY |
1827 | 0 | case CURLOPT_PROXY_KEYPASSWD: |
1828 | | /* |
1829 | | * String that holds the SSL private key password for proxy. |
1830 | | */ |
1831 | 0 | result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY], |
1832 | 0 | va_arg(param, char *)); |
1833 | 0 | break; |
1834 | 0 | #endif |
1835 | 0 | case CURLOPT_SSLENGINE: |
1836 | | /* |
1837 | | * String that holds the SSL crypto engine. |
1838 | | */ |
1839 | 0 | argptr = va_arg(param, char *); |
1840 | 0 | if(argptr && argptr[0]) { |
1841 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr); |
1842 | 0 | if(!result) { |
1843 | 0 | result = Curl_ssl_set_engine(data, argptr); |
1844 | 0 | } |
1845 | 0 | } |
1846 | 0 | break; |
1847 | | |
1848 | 0 | case CURLOPT_SSLENGINE_DEFAULT: |
1849 | | /* |
1850 | | * flag to set engine as default. |
1851 | | */ |
1852 | 0 | Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL); |
1853 | 0 | result = Curl_ssl_set_engine_default(data); |
1854 | 0 | break; |
1855 | 0 | case CURLOPT_CRLF: |
1856 | | /* |
1857 | | * Kludgy option to enable CRLF conversions. Subject for removal. |
1858 | | */ |
1859 | 0 | data->set.crlf = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1860 | 0 | break; |
1861 | 0 | #ifndef CURL_DISABLE_PROXY |
1862 | 0 | case CURLOPT_HAPROXYPROTOCOL: |
1863 | | /* |
1864 | | * Set to send the HAProxy Proxy Protocol header |
1865 | | */ |
1866 | 0 | data->set.haproxyprotocol = (0 != va_arg(param, long)) ? TRUE : FALSE; |
1867 | 0 | break; |
1868 | 0 | #endif |
1869 | 0 | case CURLOPT_INTERFACE: |
1870 | | /* |
1871 | | * Set what interface or address/hostname to bind the socket to when |
1872 | | * performing an operation and thus what from-IP your connection will use. |
1873 | | */ |
1874 | 0 | result = Curl_setstropt(&data->set.str[STRING_DEVICE], |
1875 | 0 | va_arg(param, char *)); |
1876 | 0 | break; |
1877 | 0 | case CURLOPT_LOCALPORT: |
1878 | | /* |
1879 | | * Set what local port to bind the socket to when performing an operation. |
1880 | | */ |
1881 | 0 | arg = va_arg(param, long); |
1882 | 0 | if((arg < 0) || (arg > 65535)) |
1883 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1884 | 0 | data->set.localport = curlx_sltous(arg); |
1885 | 0 | break; |
1886 | 0 | case CURLOPT_LOCALPORTRANGE: |
1887 | | /* |
1888 | | * Set number of local ports to try, starting with CURLOPT_LOCALPORT. |
1889 | | */ |
1890 | 0 | arg = va_arg(param, long); |
1891 | 0 | if((arg < 0) || (arg > 65535)) |
1892 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
1893 | 0 | data->set.localportrange = curlx_sltous(arg); |
1894 | 0 | break; |
1895 | 0 | case CURLOPT_GSSAPI_DELEGATION: |
1896 | | /* |
1897 | | * GSS-API credential delegation bitmask |
1898 | | */ |
1899 | 0 | uarg = va_arg(param, unsigned long); |
1900 | 0 | data->set.gssapi_delegation = (unsigned char)uarg& |
1901 | 0 | (CURLGSSAPI_DELEGATION_POLICY_FLAG|CURLGSSAPI_DELEGATION_FLAG); |
1902 | 0 | break; |
1903 | 0 | case CURLOPT_SSL_VERIFYPEER: |
1904 | | /* |
1905 | | * Enable peer SSL verifying. |
1906 | | */ |
1907 | 0 | data->set.ssl.primary.verifypeer = (0 != va_arg(param, long)) ? |
1908 | 0 | TRUE : FALSE; |
1909 | | |
1910 | | /* Update the current connection ssl_config. */ |
1911 | 0 | if(data->conn) { |
1912 | 0 | data->conn->ssl_config.verifypeer = |
1913 | 0 | data->set.ssl.primary.verifypeer; |
1914 | 0 | } |
1915 | 0 | break; |
1916 | 0 | #ifndef CURL_DISABLE_DOH |
1917 | 0 | case CURLOPT_DOH_SSL_VERIFYPEER: |
1918 | | /* |
1919 | | * Enable peer SSL verifying for DoH. |
1920 | | */ |
1921 | 0 | data->set.doh_verifypeer = (0 != va_arg(param, long)) ? |
1922 | 0 | TRUE : FALSE; |
1923 | 0 | break; |
1924 | 0 | #endif |
1925 | 0 | #ifndef CURL_DISABLE_PROXY |
1926 | 0 | case CURLOPT_PROXY_SSL_VERIFYPEER: |
1927 | | /* |
1928 | | * Enable peer SSL verifying for proxy. |
1929 | | */ |
1930 | 0 | data->set.proxy_ssl.primary.verifypeer = |
1931 | 0 | (0 != va_arg(param, long))?TRUE:FALSE; |
1932 | | |
1933 | | /* Update the current connection proxy_ssl_config. */ |
1934 | 0 | if(data->conn) { |
1935 | 0 | data->conn->proxy_ssl_config.verifypeer = |
1936 | 0 | data->set.proxy_ssl.primary.verifypeer; |
1937 | 0 | } |
1938 | 0 | break; |
1939 | 0 | #endif |
1940 | 0 | case CURLOPT_SSL_VERIFYHOST: |
1941 | | /* |
1942 | | * Enable verification of the host name in the peer certificate |
1943 | | */ |
1944 | 0 | arg = va_arg(param, long); |
1945 | | |
1946 | | /* Obviously people are not reading documentation and too many thought |
1947 | | this argument took a boolean when it wasn't and misused it. |
1948 | | Treat 1 and 2 the same */ |
1949 | 0 | data->set.ssl.primary.verifyhost = (bool)((arg & 3) ? TRUE : FALSE); |
1950 | | |
1951 | | /* Update the current connection ssl_config. */ |
1952 | 0 | if(data->conn) { |
1953 | 0 | data->conn->ssl_config.verifyhost = |
1954 | 0 | data->set.ssl.primary.verifyhost; |
1955 | 0 | } |
1956 | 0 | break; |
1957 | 0 | #ifndef CURL_DISABLE_DOH |
1958 | 0 | case CURLOPT_DOH_SSL_VERIFYHOST: |
1959 | | /* |
1960 | | * Enable verification of the host name in the peer certificate for DoH |
1961 | | */ |
1962 | 0 | arg = va_arg(param, long); |
1963 | | |
1964 | | /* Treat both 1 and 2 as TRUE */ |
1965 | 0 | data->set.doh_verifyhost = (bool)((arg & 3) ? TRUE : FALSE); |
1966 | 0 | break; |
1967 | 0 | #endif |
1968 | 0 | #ifndef CURL_DISABLE_PROXY |
1969 | 0 | case CURLOPT_PROXY_SSL_VERIFYHOST: |
1970 | | /* |
1971 | | * Enable verification of the host name in the peer certificate for proxy |
1972 | | */ |
1973 | 0 | arg = va_arg(param, long); |
1974 | | |
1975 | | /* Treat both 1 and 2 as TRUE */ |
1976 | 0 | data->set.proxy_ssl.primary.verifyhost = (bool)((arg & 3)?TRUE:FALSE); |
1977 | | |
1978 | | /* Update the current connection proxy_ssl_config. */ |
1979 | 0 | if(data->conn) { |
1980 | 0 | data->conn->proxy_ssl_config.verifyhost = |
1981 | 0 | data->set.proxy_ssl.primary.verifyhost; |
1982 | 0 | } |
1983 | 0 | break; |
1984 | 0 | #endif |
1985 | 0 | case CURLOPT_SSL_VERIFYSTATUS: |
1986 | | /* |
1987 | | * Enable certificate status verifying. |
1988 | | */ |
1989 | 0 | if(!Curl_ssl_cert_status_request()) { |
1990 | 0 | result = CURLE_NOT_BUILT_IN; |
1991 | 0 | break; |
1992 | 0 | } |
1993 | | |
1994 | 0 | data->set.ssl.primary.verifystatus = (0 != va_arg(param, long)) ? |
1995 | 0 | TRUE : FALSE; |
1996 | | |
1997 | | /* Update the current connection ssl_config. */ |
1998 | 0 | if(data->conn) { |
1999 | 0 | data->conn->ssl_config.verifystatus = |
2000 | 0 | data->set.ssl.primary.verifystatus; |
2001 | 0 | } |
2002 | 0 | break; |
2003 | 0 | #ifndef CURL_DISABLE_DOH |
2004 | 0 | case CURLOPT_DOH_SSL_VERIFYSTATUS: |
2005 | | /* |
2006 | | * Enable certificate status verifying for DoH. |
2007 | | */ |
2008 | 0 | if(!Curl_ssl_cert_status_request()) { |
2009 | 0 | result = CURLE_NOT_BUILT_IN; |
2010 | 0 | break; |
2011 | 0 | } |
2012 | | |
2013 | 0 | data->set.doh_verifystatus = (0 != va_arg(param, long)) ? |
2014 | 0 | TRUE : FALSE; |
2015 | 0 | break; |
2016 | 0 | #endif |
2017 | 0 | case CURLOPT_SSL_CTX_FUNCTION: |
2018 | | /* |
2019 | | * Set a SSL_CTX callback |
2020 | | */ |
2021 | | #ifdef USE_SSL |
2022 | | if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) |
2023 | | data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); |
2024 | | else |
2025 | | #endif |
2026 | 0 | result = CURLE_NOT_BUILT_IN; |
2027 | 0 | break; |
2028 | 0 | case CURLOPT_SSL_CTX_DATA: |
2029 | | /* |
2030 | | * Set a SSL_CTX callback parameter pointer |
2031 | | */ |
2032 | | #ifdef USE_SSL |
2033 | | if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) |
2034 | | data->set.ssl.fsslctxp = va_arg(param, void *); |
2035 | | else |
2036 | | #endif |
2037 | 0 | result = CURLE_NOT_BUILT_IN; |
2038 | 0 | break; |
2039 | 0 | case CURLOPT_SSL_FALSESTART: |
2040 | | /* |
2041 | | * Enable TLS false start. |
2042 | | */ |
2043 | 0 | if(!Curl_ssl_false_start(data)) { |
2044 | 0 | result = CURLE_NOT_BUILT_IN; |
2045 | 0 | break; |
2046 | 0 | } |
2047 | | |
2048 | 0 | data->set.ssl.falsestart = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2049 | 0 | break; |
2050 | 0 | case CURLOPT_CERTINFO: |
2051 | | #ifdef USE_SSL |
2052 | | if(Curl_ssl_supports(data, SSLSUPP_CERTINFO)) |
2053 | | data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2054 | | else |
2055 | | #endif |
2056 | 0 | result = CURLE_NOT_BUILT_IN; |
2057 | 0 | break; |
2058 | 0 | case CURLOPT_PINNEDPUBLICKEY: |
2059 | | /* |
2060 | | * Set pinned public key for SSL connection. |
2061 | | * Specify file name of the public key in DER format. |
2062 | | */ |
2063 | | #ifdef USE_SSL |
2064 | | if(Curl_ssl_supports(data, SSLSUPP_PINNEDPUBKEY)) |
2065 | | result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY], |
2066 | | va_arg(param, char *)); |
2067 | | else |
2068 | | #endif |
2069 | 0 | result = CURLE_NOT_BUILT_IN; |
2070 | 0 | break; |
2071 | 0 | #ifndef CURL_DISABLE_PROXY |
2072 | 0 | case CURLOPT_PROXY_PINNEDPUBLICKEY: |
2073 | | /* |
2074 | | * Set pinned public key for SSL connection. |
2075 | | * Specify file name of the public key in DER format. |
2076 | | */ |
2077 | | #ifdef USE_SSL |
2078 | | if(Curl_ssl_supports(data, SSLSUPP_PINNEDPUBKEY)) |
2079 | | result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY], |
2080 | | va_arg(param, char *)); |
2081 | | else |
2082 | | #endif |
2083 | 0 | result = CURLE_NOT_BUILT_IN; |
2084 | 0 | break; |
2085 | 0 | #endif |
2086 | 0 | case CURLOPT_CAINFO: |
2087 | | /* |
2088 | | * Set CA info for SSL connection. Specify file name of the CA certificate |
2089 | | */ |
2090 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE], |
2091 | 0 | va_arg(param, char *)); |
2092 | 0 | break; |
2093 | 0 | case CURLOPT_CAINFO_BLOB: |
2094 | | /* |
2095 | | * Blob that holds CA info for SSL connection. |
2096 | | * Specify entire PEM of the CA certificate |
2097 | | */ |
2098 | | #ifdef USE_SSL |
2099 | | if(Curl_ssl_supports(data, SSLSUPP_CAINFO_BLOB)) |
2100 | | result = Curl_setblobopt(&data->set.blobs[BLOB_CAINFO], |
2101 | | va_arg(param, struct curl_blob *)); |
2102 | | else |
2103 | | #endif |
2104 | 0 | return CURLE_NOT_BUILT_IN; |
2105 | | |
2106 | 0 | break; |
2107 | 0 | #ifndef CURL_DISABLE_PROXY |
2108 | 0 | case CURLOPT_PROXY_CAINFO: |
2109 | | /* |
2110 | | * Set CA info SSL connection for proxy. Specify file name of the |
2111 | | * CA certificate |
2112 | | */ |
2113 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY], |
2114 | 0 | va_arg(param, char *)); |
2115 | 0 | break; |
2116 | 0 | case CURLOPT_PROXY_CAINFO_BLOB: |
2117 | | /* |
2118 | | * Blob that holds CA info for SSL connection proxy. |
2119 | | * Specify entire PEM of the CA certificate |
2120 | | */ |
2121 | | #ifdef USE_SSL |
2122 | | if(Curl_ssl_supports(data, SSLSUPP_CAINFO_BLOB)) |
2123 | | result = Curl_setblobopt(&data->set.blobs[BLOB_CAINFO_PROXY], |
2124 | | va_arg(param, struct curl_blob *)); |
2125 | | else |
2126 | | #endif |
2127 | 0 | return CURLE_NOT_BUILT_IN; |
2128 | 0 | break; |
2129 | 0 | #endif |
2130 | 0 | case CURLOPT_CAPATH: |
2131 | | /* |
2132 | | * Set CA path info for SSL connection. Specify directory name of the CA |
2133 | | * certificates which have been prepared using openssl c_rehash utility. |
2134 | | */ |
2135 | | #ifdef USE_SSL |
2136 | | if(Curl_ssl_supports(data, SSLSUPP_CA_PATH)) |
2137 | | /* This does not work on windows. */ |
2138 | | result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH], |
2139 | | va_arg(param, char *)); |
2140 | | else |
2141 | | #endif |
2142 | 0 | result = CURLE_NOT_BUILT_IN; |
2143 | 0 | break; |
2144 | 0 | #ifndef CURL_DISABLE_PROXY |
2145 | 0 | case CURLOPT_PROXY_CAPATH: |
2146 | | /* |
2147 | | * Set CA path info for SSL connection proxy. Specify directory name of the |
2148 | | * CA certificates which have been prepared using openssl c_rehash utility. |
2149 | | */ |
2150 | | #ifdef USE_SSL |
2151 | | if(Curl_ssl_supports(data, SSLSUPP_CA_PATH)) |
2152 | | /* This does not work on windows. */ |
2153 | | result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY], |
2154 | | va_arg(param, char *)); |
2155 | | else |
2156 | | #endif |
2157 | 0 | result = CURLE_NOT_BUILT_IN; |
2158 | 0 | break; |
2159 | 0 | #endif |
2160 | 0 | case CURLOPT_CRLFILE: |
2161 | | /* |
2162 | | * Set CRL file info for SSL connection. Specify file name of the CRL |
2163 | | * to check certificates revocation |
2164 | | */ |
2165 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE], |
2166 | 0 | va_arg(param, char *)); |
2167 | 0 | break; |
2168 | 0 | #ifndef CURL_DISABLE_PROXY |
2169 | 0 | case CURLOPT_PROXY_CRLFILE: |
2170 | | /* |
2171 | | * Set CRL file info for SSL connection for proxy. Specify file name of the |
2172 | | * CRL to check certificates revocation |
2173 | | */ |
2174 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY], |
2175 | 0 | va_arg(param, char *)); |
2176 | 0 | break; |
2177 | 0 | #endif |
2178 | 0 | case CURLOPT_ISSUERCERT: |
2179 | | /* |
2180 | | * Set Issuer certificate file |
2181 | | * to check certificates issuer |
2182 | | */ |
2183 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT], |
2184 | 0 | va_arg(param, char *)); |
2185 | 0 | break; |
2186 | 0 | case CURLOPT_ISSUERCERT_BLOB: |
2187 | | /* |
2188 | | * Blob that holds Issuer certificate to check certificates issuer |
2189 | | */ |
2190 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT], |
2191 | 0 | va_arg(param, struct curl_blob *)); |
2192 | 0 | break; |
2193 | 0 | #ifndef CURL_DISABLE_PROXY |
2194 | 0 | case CURLOPT_PROXY_ISSUERCERT: |
2195 | | /* |
2196 | | * Set Issuer certificate file |
2197 | | * to check certificates issuer |
2198 | | */ |
2199 | 0 | result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_PROXY], |
2200 | 0 | va_arg(param, char *)); |
2201 | 0 | break; |
2202 | 0 | case CURLOPT_PROXY_ISSUERCERT_BLOB: |
2203 | | /* |
2204 | | * Blob that holds Issuer certificate to check certificates issuer |
2205 | | */ |
2206 | 0 | result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY], |
2207 | 0 | va_arg(param, struct curl_blob *)); |
2208 | 0 | break; |
2209 | 0 | #endif |
2210 | 0 | #ifndef CURL_DISABLE_TELNET |
2211 | 0 | case CURLOPT_TELNETOPTIONS: |
2212 | | /* |
2213 | | * Set a linked list of telnet options |
2214 | | */ |
2215 | 0 | data->set.telnet_options = va_arg(param, struct curl_slist *); |
2216 | 0 | break; |
2217 | 0 | #endif |
2218 | 0 | case CURLOPT_BUFFERSIZE: |
2219 | | /* |
2220 | | * The application kindly asks for a differently sized receive buffer. |
2221 | | * If it seems reasonable, we'll use it. |
2222 | | */ |
2223 | 0 | if(data->state.buffer) |
2224 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2225 | | |
2226 | 0 | arg = va_arg(param, long); |
2227 | |
|
2228 | 0 | if(arg > READBUFFER_MAX) |
2229 | 0 | arg = READBUFFER_MAX; |
2230 | 0 | else if(arg < 1) |
2231 | 0 | arg = READBUFFER_SIZE; |
2232 | 0 | else if(arg < READBUFFER_MIN) |
2233 | 0 | arg = READBUFFER_MIN; |
2234 | |
|
2235 | 0 | data->set.buffer_size = (unsigned int)arg; |
2236 | 0 | break; |
2237 | | |
2238 | 0 | case CURLOPT_UPLOAD_BUFFERSIZE: |
2239 | | /* |
2240 | | * The application kindly asks for a differently sized upload buffer. |
2241 | | * Cap it to sensible. |
2242 | | */ |
2243 | 0 | arg = va_arg(param, long); |
2244 | |
|
2245 | 0 | if(arg > UPLOADBUFFER_MAX) |
2246 | 0 | arg = UPLOADBUFFER_MAX; |
2247 | 0 | else if(arg < UPLOADBUFFER_MIN) |
2248 | 0 | arg = UPLOADBUFFER_MIN; |
2249 | |
|
2250 | 0 | data->set.upload_buffer_size = (unsigned int)arg; |
2251 | 0 | Curl_safefree(data->state.ulbuf); /* force a realloc next opportunity */ |
2252 | 0 | break; |
2253 | | |
2254 | 0 | case CURLOPT_NOSIGNAL: |
2255 | | /* |
2256 | | * The application asks not to set any signal() or alarm() handlers, |
2257 | | * even when using a timeout. |
2258 | | */ |
2259 | 0 | data->set.no_signal = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2260 | 0 | break; |
2261 | | |
2262 | 0 | case CURLOPT_SHARE: |
2263 | 0 | { |
2264 | 0 | struct Curl_share *set; |
2265 | 0 | set = va_arg(param, struct Curl_share *); |
2266 | | |
2267 | | /* disconnect from old share, if any */ |
2268 | 0 | if(data->share) { |
2269 | 0 | Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); |
2270 | |
|
2271 | 0 | if(data->dns.hostcachetype == HCACHE_SHARED) { |
2272 | 0 | data->dns.hostcache = NULL; |
2273 | 0 | data->dns.hostcachetype = HCACHE_NONE; |
2274 | 0 | } |
2275 | |
|
2276 | 0 | #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) |
2277 | 0 | if(data->share->cookies == data->cookies) |
2278 | 0 | data->cookies = NULL; |
2279 | 0 | #endif |
2280 | |
|
2281 | | #ifndef CURL_DISABLE_HSTS |
2282 | | if(data->share->hsts == data->hsts) |
2283 | | data->hsts = NULL; |
2284 | | #endif |
2285 | | #ifdef USE_SSL |
2286 | | if(data->share->sslsession == data->state.session) |
2287 | | data->state.session = NULL; |
2288 | | #endif |
2289 | | #ifdef USE_LIBPSL |
2290 | | if(data->psl == &data->share->psl) |
2291 | | data->psl = data->multi? &data->multi->psl: NULL; |
2292 | | #endif |
2293 | |
|
2294 | 0 | data->share->dirty--; |
2295 | |
|
2296 | 0 | Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); |
2297 | 0 | data->share = NULL; |
2298 | 0 | } |
2299 | |
|
2300 | 0 | if(GOOD_SHARE_HANDLE(set)) |
2301 | | /* use new share if it set */ |
2302 | 0 | data->share = set; |
2303 | 0 | if(data->share) { |
2304 | |
|
2305 | 0 | Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); |
2306 | |
|
2307 | 0 | data->share->dirty++; |
2308 | |
|
2309 | 0 | if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) { |
2310 | | /* use shared host cache */ |
2311 | 0 | data->dns.hostcache = &data->share->hostcache; |
2312 | 0 | data->dns.hostcachetype = HCACHE_SHARED; |
2313 | 0 | } |
2314 | 0 | #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) |
2315 | 0 | if(data->share->cookies) { |
2316 | | /* use shared cookie list, first free own one if any */ |
2317 | 0 | Curl_cookie_cleanup(data->cookies); |
2318 | | /* enable cookies since we now use a share that uses cookies! */ |
2319 | 0 | data->cookies = data->share->cookies; |
2320 | 0 | } |
2321 | 0 | #endif /* CURL_DISABLE_HTTP */ |
2322 | | #ifndef CURL_DISABLE_HSTS |
2323 | | if(data->share->hsts) { |
2324 | | /* first free the private one if any */ |
2325 | | Curl_hsts_cleanup(&data->hsts); |
2326 | | data->hsts = data->share->hsts; |
2327 | | } |
2328 | | #endif /* CURL_DISABLE_HTTP */ |
2329 | | #ifdef USE_SSL |
2330 | | if(data->share->sslsession) { |
2331 | | data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions; |
2332 | | data->state.session = data->share->sslsession; |
2333 | | } |
2334 | | #endif |
2335 | | #ifdef USE_LIBPSL |
2336 | | if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL)) |
2337 | | data->psl = &data->share->psl; |
2338 | | #endif |
2339 | |
|
2340 | 0 | Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); |
2341 | 0 | } |
2342 | | /* check for host cache not needed, |
2343 | | * it will be done by curl_easy_perform */ |
2344 | 0 | } |
2345 | 0 | break; |
2346 | | |
2347 | 0 | case CURLOPT_PRIVATE: |
2348 | | /* |
2349 | | * Set private data pointer. |
2350 | | */ |
2351 | 0 | data->set.private_data = va_arg(param, void *); |
2352 | 0 | break; |
2353 | | |
2354 | 0 | case CURLOPT_MAXFILESIZE: |
2355 | | /* |
2356 | | * Set the maximum size of a file to download. |
2357 | | */ |
2358 | 0 | arg = va_arg(param, long); |
2359 | 0 | if(arg < 0) |
2360 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2361 | 0 | data->set.max_filesize = arg; |
2362 | 0 | break; |
2363 | | |
2364 | | #ifdef USE_SSL |
2365 | | case CURLOPT_USE_SSL: |
2366 | | /* |
2367 | | * Make transfers attempt to use SSL/TLS. |
2368 | | */ |
2369 | | arg = va_arg(param, long); |
2370 | | if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST)) |
2371 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
2372 | | data->set.use_ssl = (unsigned char)arg; |
2373 | | break; |
2374 | | |
2375 | | case CURLOPT_SSL_OPTIONS: |
2376 | | arg = va_arg(param, long); |
2377 | | data->set.ssl.primary.ssl_options = (unsigned char)(arg & 0xff); |
2378 | | data->set.ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST); |
2379 | | data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE); |
2380 | | data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN); |
2381 | | data->set.ssl.revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT); |
2382 | | data->set.ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA); |
2383 | | data->set.ssl.auto_client_cert = !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT); |
2384 | | /* If a setting is added here it should also be added in dohprobe() |
2385 | | which sets its own CURLOPT_SSL_OPTIONS based on these settings. */ |
2386 | | break; |
2387 | | |
2388 | | #ifndef CURL_DISABLE_PROXY |
2389 | | case CURLOPT_PROXY_SSL_OPTIONS: |
2390 | | arg = va_arg(param, long); |
2391 | | data->set.proxy_ssl.primary.ssl_options = (unsigned char)(arg & 0xff); |
2392 | | data->set.proxy_ssl.enable_beast = !!(arg & CURLSSLOPT_ALLOW_BEAST); |
2393 | | data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE); |
2394 | | data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN); |
2395 | | data->set.proxy_ssl.revoke_best_effort = |
2396 | | !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT); |
2397 | | data->set.proxy_ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA); |
2398 | | data->set.proxy_ssl.auto_client_cert = |
2399 | | !!(arg & CURLSSLOPT_AUTO_CLIENT_CERT); |
2400 | | break; |
2401 | | #endif |
2402 | | |
2403 | | case CURLOPT_SSL_EC_CURVES: |
2404 | | /* |
2405 | | * Set accepted curves in SSL connection setup. |
2406 | | * Specify colon-delimited list of curve algorithm names. |
2407 | | */ |
2408 | | result = Curl_setstropt(&data->set.str[STRING_SSL_EC_CURVES], |
2409 | | va_arg(param, char *)); |
2410 | | break; |
2411 | | #endif |
2412 | 0 | case CURLOPT_IPRESOLVE: |
2413 | 0 | arg = va_arg(param, long); |
2414 | 0 | if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6)) |
2415 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2416 | 0 | data->set.ipver = (unsigned char) arg; |
2417 | 0 | break; |
2418 | | |
2419 | 0 | case CURLOPT_MAXFILESIZE_LARGE: |
2420 | | /* |
2421 | | * Set the maximum size of a file to download. |
2422 | | */ |
2423 | 0 | bigsize = va_arg(param, curl_off_t); |
2424 | 0 | if(bigsize < 0) |
2425 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2426 | 0 | data->set.max_filesize = bigsize; |
2427 | 0 | break; |
2428 | | |
2429 | 0 | case CURLOPT_TCP_NODELAY: |
2430 | | /* |
2431 | | * Enable or disable TCP_NODELAY, which will disable/enable the Nagle |
2432 | | * algorithm |
2433 | | */ |
2434 | 0 | data->set.tcp_nodelay = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2435 | 0 | break; |
2436 | | |
2437 | 0 | case CURLOPT_IGNORE_CONTENT_LENGTH: |
2438 | 0 | data->set.ignorecl = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2439 | 0 | break; |
2440 | | |
2441 | 33 | case CURLOPT_CONNECT_ONLY: |
2442 | | /* |
2443 | | * No data transfer. |
2444 | | * (1) - only do connection |
2445 | | * (2) - do first get request but get no content |
2446 | | */ |
2447 | 33 | arg = va_arg(param, long); |
2448 | 33 | if(arg > 2) |
2449 | 29 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2450 | 4 | data->set.connect_only = (unsigned char)arg; |
2451 | 4 | break; |
2452 | | |
2453 | 690 | case CURLOPT_SOCKOPTFUNCTION: |
2454 | | /* |
2455 | | * socket callback function: called after socket() but before connect() |
2456 | | */ |
2457 | 690 | data->set.fsockopt = va_arg(param, curl_sockopt_callback); |
2458 | 690 | break; |
2459 | | |
2460 | 0 | case CURLOPT_SOCKOPTDATA: |
2461 | | /* |
2462 | | * socket callback data pointer. Might be NULL. |
2463 | | */ |
2464 | 0 | data->set.sockopt_client = va_arg(param, void *); |
2465 | 0 | break; |
2466 | | |
2467 | 690 | case CURLOPT_OPENSOCKETFUNCTION: |
2468 | | /* |
2469 | | * open/create socket callback function: called instead of socket(), |
2470 | | * before connect() |
2471 | | */ |
2472 | 690 | data->set.fopensocket = va_arg(param, curl_opensocket_callback); |
2473 | 690 | break; |
2474 | | |
2475 | 690 | case CURLOPT_OPENSOCKETDATA: |
2476 | | /* |
2477 | | * socket callback data pointer. Might be NULL. |
2478 | | */ |
2479 | 690 | data->set.opensocket_client = va_arg(param, void *); |
2480 | 690 | break; |
2481 | | |
2482 | 0 | case CURLOPT_CLOSESOCKETFUNCTION: |
2483 | | /* |
2484 | | * close socket callback function: called instead of close() |
2485 | | * when shutting down a connection |
2486 | | */ |
2487 | 0 | data->set.fclosesocket = va_arg(param, curl_closesocket_callback); |
2488 | 0 | break; |
2489 | | |
2490 | 0 | case CURLOPT_RESOLVER_START_FUNCTION: |
2491 | | /* |
2492 | | * resolver start callback function: called before a new resolver request |
2493 | | * is started |
2494 | | */ |
2495 | 0 | data->set.resolver_start = va_arg(param, curl_resolver_start_callback); |
2496 | 0 | break; |
2497 | | |
2498 | 0 | case CURLOPT_RESOLVER_START_DATA: |
2499 | | /* |
2500 | | * resolver start callback data pointer. Might be NULL. |
2501 | | */ |
2502 | 0 | data->set.resolver_start_client = va_arg(param, void *); |
2503 | 0 | break; |
2504 | | |
2505 | 0 | case CURLOPT_CLOSESOCKETDATA: |
2506 | | /* |
2507 | | * socket callback data pointer. Might be NULL. |
2508 | | */ |
2509 | 0 | data->set.closesocket_client = va_arg(param, void *); |
2510 | 0 | break; |
2511 | | |
2512 | 0 | case CURLOPT_SSL_SESSIONID_CACHE: |
2513 | 0 | data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ? |
2514 | 0 | TRUE : FALSE; |
2515 | 0 | #ifndef CURL_DISABLE_PROXY |
2516 | 0 | data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid; |
2517 | 0 | #endif |
2518 | 0 | break; |
2519 | | |
2520 | | #ifdef USE_SSH |
2521 | | /* we only include SSH options if explicitly built to support SSH */ |
2522 | | case CURLOPT_SSH_AUTH_TYPES: |
2523 | | data->set.ssh_auth_types = (unsigned int)va_arg(param, long); |
2524 | | break; |
2525 | | |
2526 | | case CURLOPT_SSH_PUBLIC_KEYFILE: |
2527 | | /* |
2528 | | * Use this file instead of the $HOME/.ssh/id_dsa.pub file |
2529 | | */ |
2530 | | result = Curl_setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY], |
2531 | | va_arg(param, char *)); |
2532 | | break; |
2533 | | |
2534 | | case CURLOPT_SSH_PRIVATE_KEYFILE: |
2535 | | /* |
2536 | | * Use this file instead of the $HOME/.ssh/id_dsa file |
2537 | | */ |
2538 | | result = Curl_setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY], |
2539 | | va_arg(param, char *)); |
2540 | | break; |
2541 | | case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: |
2542 | | /* |
2543 | | * Option to allow for the MD5 of the host public key to be checked |
2544 | | * for validation purposes. |
2545 | | */ |
2546 | | result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5], |
2547 | | va_arg(param, char *)); |
2548 | | break; |
2549 | | |
2550 | | case CURLOPT_SSH_KNOWNHOSTS: |
2551 | | /* |
2552 | | * Store the file name to read known hosts from. |
2553 | | */ |
2554 | | result = Curl_setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS], |
2555 | | va_arg(param, char *)); |
2556 | | break; |
2557 | | #ifdef USE_LIBSSH2 |
2558 | | case CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256: |
2559 | | /* |
2560 | | * Option to allow for the SHA256 of the host public key to be checked |
2561 | | * for validation purposes. |
2562 | | */ |
2563 | | result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_SHA256], |
2564 | | va_arg(param, char *)); |
2565 | | break; |
2566 | | |
2567 | | case CURLOPT_SSH_HOSTKEYFUNCTION: |
2568 | | /* the callback to check the hostkey without the knownhost file */ |
2569 | | data->set.ssh_hostkeyfunc = va_arg(param, curl_sshhostkeycallback); |
2570 | | break; |
2571 | | |
2572 | | case CURLOPT_SSH_HOSTKEYDATA: |
2573 | | /* |
2574 | | * Custom client data to pass to the SSH keyfunc callback |
2575 | | */ |
2576 | | data->set.ssh_hostkeyfunc_userp = va_arg(param, void *); |
2577 | | break; |
2578 | | #endif |
2579 | | |
2580 | | case CURLOPT_SSH_KEYFUNCTION: |
2581 | | /* setting to NULL is fine since the ssh.c functions themselves will |
2582 | | then revert to use the internal default */ |
2583 | | data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback); |
2584 | | break; |
2585 | | |
2586 | | case CURLOPT_SSH_KEYDATA: |
2587 | | /* |
2588 | | * Custom client data to pass to the SSH keyfunc callback |
2589 | | */ |
2590 | | data->set.ssh_keyfunc_userp = va_arg(param, void *); |
2591 | | break; |
2592 | | |
2593 | | case CURLOPT_SSH_COMPRESSION: |
2594 | | data->set.ssh_compression = (0 != va_arg(param, long))?TRUE:FALSE; |
2595 | | break; |
2596 | | #endif /* USE_SSH */ |
2597 | | |
2598 | 0 | case CURLOPT_HTTP_TRANSFER_DECODING: |
2599 | | /* |
2600 | | * disable libcurl transfer encoding is used |
2601 | | */ |
2602 | 0 | #ifndef USE_HYPER |
2603 | 0 | data->set.http_te_skip = (0 == va_arg(param, long)) ? TRUE : FALSE; |
2604 | 0 | break; |
2605 | | #else |
2606 | | return CURLE_NOT_BUILT_IN; /* hyper doesn't support */ |
2607 | | #endif |
2608 | | |
2609 | 0 | case CURLOPT_HTTP_CONTENT_DECODING: |
2610 | | /* |
2611 | | * raw data passed to the application when content encoding is used |
2612 | | */ |
2613 | 0 | data->set.http_ce_skip = (0 == va_arg(param, long)) ? TRUE : FALSE; |
2614 | 0 | break; |
2615 | | |
2616 | 0 | #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) |
2617 | 0 | case CURLOPT_NEW_FILE_PERMS: |
2618 | | /* |
2619 | | * Uses these permissions instead of 0644 |
2620 | | */ |
2621 | 0 | arg = va_arg(param, long); |
2622 | 0 | if((arg < 0) || (arg > 0777)) |
2623 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2624 | 0 | data->set.new_file_perms = (unsigned int)arg; |
2625 | 0 | break; |
2626 | 0 | #endif |
2627 | | #ifdef USE_SSH |
2628 | | case CURLOPT_NEW_DIRECTORY_PERMS: |
2629 | | /* |
2630 | | * Uses these permissions instead of 0755 |
2631 | | */ |
2632 | | arg = va_arg(param, long); |
2633 | | if((arg < 0) || (arg > 0777)) |
2634 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
2635 | | data->set.new_directory_perms = (unsigned int)arg; |
2636 | | break; |
2637 | | #endif |
2638 | | |
2639 | 0 | #ifdef ENABLE_IPV6 |
2640 | 0 | case CURLOPT_ADDRESS_SCOPE: |
2641 | | /* |
2642 | | * Use this scope id when using IPv6 |
2643 | | * We always get longs when passed plain numericals so we should check |
2644 | | * that the value fits into an unsigned 32 bit integer. |
2645 | | */ |
2646 | 0 | uarg = va_arg(param, unsigned long); |
2647 | 0 | #if SIZEOF_LONG > 4 |
2648 | 0 | if(uarg > UINT_MAX) |
2649 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2650 | 0 | #endif |
2651 | 0 | data->set.scope_id = (unsigned int)uarg; |
2652 | 0 | break; |
2653 | 0 | #endif |
2654 | | |
2655 | 0 | case CURLOPT_PROTOCOLS: |
2656 | | /* set the bitmask for the protocols that are allowed to be used for the |
2657 | | transfer, which thus helps the app which takes URLs from users or other |
2658 | | external inputs and want to restrict what protocol(s) to deal |
2659 | | with. Defaults to CURLPROTO_ALL. */ |
2660 | 0 | data->set.allowed_protocols = (curl_prot_t)va_arg(param, long); |
2661 | 0 | break; |
2662 | | |
2663 | 0 | case CURLOPT_REDIR_PROTOCOLS: |
2664 | | /* set the bitmask for the protocols that libcurl is allowed to follow to, |
2665 | | as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs |
2666 | | to be set in both bitmasks to be allowed to get redirected to. */ |
2667 | 0 | data->set.redir_protocols = (curl_prot_t)va_arg(param, long); |
2668 | 0 | break; |
2669 | | |
2670 | 0 | case CURLOPT_PROTOCOLS_STR: { |
2671 | 0 | curl_prot_t prot; |
2672 | 0 | argptr = va_arg(param, char *); |
2673 | 0 | result = protocol2num(argptr, &prot); |
2674 | 0 | if(result) |
2675 | 0 | return result; |
2676 | 0 | data->set.allowed_protocols = prot; |
2677 | 0 | break; |
2678 | 0 | } |
2679 | | |
2680 | 0 | case CURLOPT_REDIR_PROTOCOLS_STR: { |
2681 | 0 | curl_prot_t prot; |
2682 | 0 | argptr = va_arg(param, char *); |
2683 | 0 | result = protocol2num(argptr, &prot); |
2684 | 0 | if(result) |
2685 | 0 | return result; |
2686 | 0 | data->set.redir_protocols = prot; |
2687 | 0 | break; |
2688 | 0 | } |
2689 | | |
2690 | 0 | case CURLOPT_DEFAULT_PROTOCOL: |
2691 | | /* Set the protocol to use when the URL doesn't include any protocol */ |
2692 | 0 | result = Curl_setstropt(&data->set.str[STRING_DEFAULT_PROTOCOL], |
2693 | 0 | va_arg(param, char *)); |
2694 | 0 | break; |
2695 | 0 | #ifndef CURL_DISABLE_SMTP |
2696 | 8 | case CURLOPT_MAIL_FROM: |
2697 | | /* Set the SMTP mail originator */ |
2698 | 8 | result = Curl_setstropt(&data->set.str[STRING_MAIL_FROM], |
2699 | 8 | va_arg(param, char *)); |
2700 | 8 | break; |
2701 | | |
2702 | 4 | case CURLOPT_MAIL_AUTH: |
2703 | | /* Set the SMTP auth originator */ |
2704 | 4 | result = Curl_setstropt(&data->set.str[STRING_MAIL_AUTH], |
2705 | 4 | va_arg(param, char *)); |
2706 | 4 | break; |
2707 | | |
2708 | 0 | case CURLOPT_MAIL_RCPT: |
2709 | | /* Set the list of mail recipients */ |
2710 | 0 | data->set.mail_rcpt = va_arg(param, struct curl_slist *); |
2711 | 0 | break; |
2712 | 0 | case CURLOPT_MAIL_RCPT_ALLLOWFAILS: |
2713 | | /* allow RCPT TO command to fail for some recipients */ |
2714 | 0 | data->set.mail_rcpt_allowfails = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2715 | 0 | break; |
2716 | 0 | #endif |
2717 | | |
2718 | 0 | case CURLOPT_SASL_AUTHZID: |
2719 | | /* Authorization identity (identity to act as) */ |
2720 | 0 | result = Curl_setstropt(&data->set.str[STRING_SASL_AUTHZID], |
2721 | 0 | va_arg(param, char *)); |
2722 | 0 | break; |
2723 | | |
2724 | 0 | case CURLOPT_SASL_IR: |
2725 | | /* Enable/disable SASL initial response */ |
2726 | 0 | data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2727 | 0 | break; |
2728 | 0 | #ifndef CURL_DISABLE_RTSP |
2729 | 42 | case CURLOPT_RTSP_REQUEST: |
2730 | 42 | { |
2731 | | /* |
2732 | | * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...) |
2733 | | * Would this be better if the RTSPREQ_* were just moved into here? |
2734 | | */ |
2735 | 42 | long in_rtspreq = va_arg(param, long); |
2736 | 42 | Curl_RtspReq rtspreq = RTSPREQ_NONE; |
2737 | 42 | switch(in_rtspreq) { |
2738 | 0 | case CURL_RTSPREQ_OPTIONS: |
2739 | 0 | rtspreq = RTSPREQ_OPTIONS; |
2740 | 0 | break; |
2741 | | |
2742 | 0 | case CURL_RTSPREQ_DESCRIBE: |
2743 | 0 | rtspreq = RTSPREQ_DESCRIBE; |
2744 | 0 | break; |
2745 | | |
2746 | 1 | case CURL_RTSPREQ_ANNOUNCE: |
2747 | 1 | rtspreq = RTSPREQ_ANNOUNCE; |
2748 | 1 | break; |
2749 | | |
2750 | 0 | case CURL_RTSPREQ_SETUP: |
2751 | 0 | rtspreq = RTSPREQ_SETUP; |
2752 | 0 | break; |
2753 | | |
2754 | 0 | case CURL_RTSPREQ_PLAY: |
2755 | 0 | rtspreq = RTSPREQ_PLAY; |
2756 | 0 | break; |
2757 | | |
2758 | 0 | case CURL_RTSPREQ_PAUSE: |
2759 | 0 | rtspreq = RTSPREQ_PAUSE; |
2760 | 0 | break; |
2761 | | |
2762 | 1 | case CURL_RTSPREQ_TEARDOWN: |
2763 | 1 | rtspreq = RTSPREQ_TEARDOWN; |
2764 | 1 | break; |
2765 | | |
2766 | 0 | case CURL_RTSPREQ_GET_PARAMETER: |
2767 | 0 | rtspreq = RTSPREQ_GET_PARAMETER; |
2768 | 0 | break; |
2769 | | |
2770 | 0 | case CURL_RTSPREQ_SET_PARAMETER: |
2771 | 0 | rtspreq = RTSPREQ_SET_PARAMETER; |
2772 | 0 | break; |
2773 | | |
2774 | 1 | case CURL_RTSPREQ_RECORD: |
2775 | 1 | rtspreq = RTSPREQ_RECORD; |
2776 | 1 | break; |
2777 | | |
2778 | 1 | case CURL_RTSPREQ_RECEIVE: |
2779 | 1 | rtspreq = RTSPREQ_RECEIVE; |
2780 | 1 | break; |
2781 | 38 | default: |
2782 | 38 | rtspreq = RTSPREQ_NONE; |
2783 | 42 | } |
2784 | | |
2785 | 42 | data->set.rtspreq = rtspreq; |
2786 | 42 | break; |
2787 | 42 | } |
2788 | | |
2789 | | |
2790 | 6 | case CURLOPT_RTSP_SESSION_ID: |
2791 | | /* |
2792 | | * Set the RTSP Session ID manually. Useful if the application is |
2793 | | * resuming a previously established RTSP session |
2794 | | */ |
2795 | 6 | result = Curl_setstropt(&data->set.str[STRING_RTSP_SESSION_ID], |
2796 | 6 | va_arg(param, char *)); |
2797 | 6 | break; |
2798 | | |
2799 | 6 | case CURLOPT_RTSP_STREAM_URI: |
2800 | | /* |
2801 | | * Set the Stream URI for the RTSP request. Unless the request is |
2802 | | * for generic server options, the application will need to set this. |
2803 | | */ |
2804 | 6 | result = Curl_setstropt(&data->set.str[STRING_RTSP_STREAM_URI], |
2805 | 6 | va_arg(param, char *)); |
2806 | 6 | break; |
2807 | | |
2808 | 5 | case CURLOPT_RTSP_TRANSPORT: |
2809 | | /* |
2810 | | * The content of the Transport: header for the RTSP request |
2811 | | */ |
2812 | 5 | result = Curl_setstropt(&data->set.str[STRING_RTSP_TRANSPORT], |
2813 | 5 | va_arg(param, char *)); |
2814 | 5 | break; |
2815 | | |
2816 | 3 | case CURLOPT_RTSP_CLIENT_CSEQ: |
2817 | | /* |
2818 | | * Set the CSEQ number to issue for the next RTSP request. Useful if the |
2819 | | * application is resuming a previously broken connection. The CSEQ |
2820 | | * will increment from this new number henceforth. |
2821 | | */ |
2822 | 3 | data->state.rtsp_next_client_CSeq = va_arg(param, long); |
2823 | 3 | break; |
2824 | | |
2825 | 0 | case CURLOPT_RTSP_SERVER_CSEQ: |
2826 | | /* Same as the above, but for server-initiated requests */ |
2827 | 0 | data->state.rtsp_next_server_CSeq = va_arg(param, long); |
2828 | 0 | break; |
2829 | | |
2830 | 0 | case CURLOPT_INTERLEAVEDATA: |
2831 | 0 | data->set.rtp_out = va_arg(param, void *); |
2832 | 0 | break; |
2833 | 0 | case CURLOPT_INTERLEAVEFUNCTION: |
2834 | | /* Set the user defined RTP write function */ |
2835 | 0 | data->set.fwrite_rtp = va_arg(param, curl_write_callback); |
2836 | 0 | break; |
2837 | 0 | #endif |
2838 | 0 | #ifndef CURL_DISABLE_FTP |
2839 | 37 | case CURLOPT_WILDCARDMATCH: |
2840 | 37 | data->set.wildcard_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2841 | 37 | break; |
2842 | 0 | case CURLOPT_CHUNK_BGN_FUNCTION: |
2843 | 0 | data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback); |
2844 | 0 | break; |
2845 | 0 | case CURLOPT_CHUNK_END_FUNCTION: |
2846 | 0 | data->set.chunk_end = va_arg(param, curl_chunk_end_callback); |
2847 | 0 | break; |
2848 | 0 | case CURLOPT_FNMATCH_FUNCTION: |
2849 | 0 | data->set.fnmatch = va_arg(param, curl_fnmatch_callback); |
2850 | 0 | break; |
2851 | 0 | case CURLOPT_CHUNK_DATA: |
2852 | 0 | data->set.wildcardptr = va_arg(param, void *); |
2853 | 0 | break; |
2854 | 0 | case CURLOPT_FNMATCH_DATA: |
2855 | 0 | data->set.fnmatch_data = va_arg(param, void *); |
2856 | 0 | break; |
2857 | 0 | #endif |
2858 | | #ifdef USE_TLS_SRP |
2859 | | case CURLOPT_TLSAUTH_USERNAME: |
2860 | | result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME], |
2861 | | va_arg(param, char *)); |
2862 | | break; |
2863 | | #ifndef CURL_DISABLE_PROXY |
2864 | | case CURLOPT_PROXY_TLSAUTH_USERNAME: |
2865 | | result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY], |
2866 | | va_arg(param, char *)); |
2867 | | break; |
2868 | | #endif |
2869 | | case CURLOPT_TLSAUTH_PASSWORD: |
2870 | | result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD], |
2871 | | va_arg(param, char *)); |
2872 | | break; |
2873 | | #ifndef CURL_DISABLE_PROXY |
2874 | | case CURLOPT_PROXY_TLSAUTH_PASSWORD: |
2875 | | result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY], |
2876 | | va_arg(param, char *)); |
2877 | | break; |
2878 | | #endif |
2879 | | case CURLOPT_TLSAUTH_TYPE: |
2880 | | argptr = va_arg(param, char *); |
2881 | | if(argptr && !strncasecompare(argptr, "SRP", strlen("SRP"))) |
2882 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
2883 | | break; |
2884 | | #ifndef CURL_DISABLE_PROXY |
2885 | | case CURLOPT_PROXY_TLSAUTH_TYPE: |
2886 | | argptr = va_arg(param, char *); |
2887 | | if(argptr || !strncasecompare(argptr, "SRP", strlen("SRP"))) |
2888 | | return CURLE_BAD_FUNCTION_ARGUMENT; |
2889 | | break; |
2890 | | #endif |
2891 | | #endif |
2892 | | #ifdef USE_ARES |
2893 | | case CURLOPT_DNS_SERVERS: |
2894 | | result = Curl_setstropt(&data->set.str[STRING_DNS_SERVERS], |
2895 | | va_arg(param, char *)); |
2896 | | if(result) |
2897 | | return result; |
2898 | | result = Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]); |
2899 | | break; |
2900 | | case CURLOPT_DNS_INTERFACE: |
2901 | | result = Curl_setstropt(&data->set.str[STRING_DNS_INTERFACE], |
2902 | | va_arg(param, char *)); |
2903 | | if(result) |
2904 | | return result; |
2905 | | result = Curl_set_dns_interface(data, data->set.str[STRING_DNS_INTERFACE]); |
2906 | | break; |
2907 | | case CURLOPT_DNS_LOCAL_IP4: |
2908 | | result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP4], |
2909 | | va_arg(param, char *)); |
2910 | | if(result) |
2911 | | return result; |
2912 | | result = Curl_set_dns_local_ip4(data, data->set.str[STRING_DNS_LOCAL_IP4]); |
2913 | | break; |
2914 | | case CURLOPT_DNS_LOCAL_IP6: |
2915 | | result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP6], |
2916 | | va_arg(param, char *)); |
2917 | | if(result) |
2918 | | return result; |
2919 | | result = Curl_set_dns_local_ip6(data, data->set.str[STRING_DNS_LOCAL_IP6]); |
2920 | | break; |
2921 | | #endif |
2922 | 0 | case CURLOPT_TCP_KEEPALIVE: |
2923 | 0 | data->set.tcp_keepalive = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2924 | 0 | break; |
2925 | 0 | case CURLOPT_TCP_KEEPIDLE: |
2926 | 0 | arg = va_arg(param, long); |
2927 | 0 | if(arg < 0) |
2928 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2929 | 0 | else if(arg > INT_MAX) |
2930 | 0 | arg = INT_MAX; |
2931 | 0 | data->set.tcp_keepidle = (int)arg; |
2932 | 0 | break; |
2933 | 0 | case CURLOPT_TCP_KEEPINTVL: |
2934 | 0 | arg = va_arg(param, long); |
2935 | 0 | if(arg < 0) |
2936 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
2937 | 0 | else if(arg > INT_MAX) |
2938 | 0 | arg = INT_MAX; |
2939 | 0 | data->set.tcp_keepintvl = (int)arg; |
2940 | 0 | break; |
2941 | 0 | case CURLOPT_TCP_FASTOPEN: |
2942 | 0 | #if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \ |
2943 | 0 | defined(TCP_FASTOPEN_CONNECT) |
2944 | 0 | data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE; |
2945 | | #else |
2946 | | result = CURLE_NOT_BUILT_IN; |
2947 | | #endif |
2948 | 0 | break; |
2949 | 0 | case CURLOPT_SSL_ENABLE_NPN: |
2950 | 0 | break; |
2951 | 0 | case CURLOPT_SSL_ENABLE_ALPN: |
2952 | 0 | data->set.ssl_enable_alpn = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2953 | 0 | break; |
2954 | 0 | #ifdef USE_UNIX_SOCKETS |
2955 | 0 | case CURLOPT_UNIX_SOCKET_PATH: |
2956 | 0 | data->set.abstract_unix_socket = FALSE; |
2957 | 0 | result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH], |
2958 | 0 | va_arg(param, char *)); |
2959 | 0 | break; |
2960 | 0 | case CURLOPT_ABSTRACT_UNIX_SOCKET: |
2961 | 0 | data->set.abstract_unix_socket = TRUE; |
2962 | 0 | result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH], |
2963 | 0 | va_arg(param, char *)); |
2964 | 0 | break; |
2965 | 0 | #endif |
2966 | | |
2967 | 0 | case CURLOPT_PATH_AS_IS: |
2968 | 0 | data->set.path_as_is = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2969 | 0 | break; |
2970 | 0 | case CURLOPT_PIPEWAIT: |
2971 | 0 | data->set.pipewait = (0 != va_arg(param, long)) ? TRUE : FALSE; |
2972 | 0 | break; |
2973 | 0 | case CURLOPT_STREAM_WEIGHT: |
2974 | 0 | #if defined(USE_HTTP2) || defined(USE_HTTP3) |
2975 | 0 | arg = va_arg(param, long); |
2976 | 0 | if((arg >= 1) && (arg <= 256)) |
2977 | 0 | data->set.priority.weight = (int)arg; |
2978 | 0 | break; |
2979 | | #else |
2980 | | return CURLE_NOT_BUILT_IN; |
2981 | | #endif |
2982 | 0 | case CURLOPT_STREAM_DEPENDS: |
2983 | 0 | case CURLOPT_STREAM_DEPENDS_E: |
2984 | 0 | { |
2985 | 0 | struct Curl_easy *dep = va_arg(param, struct Curl_easy *); |
2986 | 0 | if(!dep || GOOD_EASY_HANDLE(dep)) { |
2987 | 0 | return Curl_data_priority_add_child(dep, data, |
2988 | 0 | option == CURLOPT_STREAM_DEPENDS_E); |
2989 | 0 | } |
2990 | 0 | break; |
2991 | 0 | } |
2992 | 0 | case CURLOPT_CONNECT_TO: |
2993 | 0 | data->set.connect_to = va_arg(param, struct curl_slist *); |
2994 | 0 | break; |
2995 | 0 | case CURLOPT_SUPPRESS_CONNECT_HEADERS: |
2996 | 0 | data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE; |
2997 | 0 | break; |
2998 | 0 | case CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS: |
2999 | 0 | uarg = va_arg(param, unsigned long); |
3000 | 0 | if(uarg > UINT_MAX) |
3001 | 0 | uarg = UINT_MAX; |
3002 | 0 | data->set.happy_eyeballs_timeout = (unsigned int)uarg; |
3003 | 0 | break; |
3004 | 0 | #ifndef CURL_DISABLE_SHUFFLE_DNS |
3005 | 0 | case CURLOPT_DNS_SHUFFLE_ADDRESSES: |
3006 | 0 | data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE; |
3007 | 0 | break; |
3008 | 0 | #endif |
3009 | 0 | case CURLOPT_DISALLOW_USERNAME_IN_URL: |
3010 | 0 | data->set.disallow_username_in_url = |
3011 | 0 | (0 != va_arg(param, long)) ? TRUE : FALSE; |
3012 | 0 | break; |
3013 | 0 | #ifndef CURL_DISABLE_DOH |
3014 | 5 | case CURLOPT_DOH_URL: |
3015 | 5 | result = Curl_setstropt(&data->set.str[STRING_DOH], |
3016 | 5 | va_arg(param, char *)); |
3017 | 5 | data->set.doh = data->set.str[STRING_DOH]?TRUE:FALSE; |
3018 | 5 | break; |
3019 | 0 | #endif |
3020 | 0 | case CURLOPT_UPKEEP_INTERVAL_MS: |
3021 | 0 | arg = va_arg(param, long); |
3022 | 0 | if(arg < 0) |
3023 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
3024 | 0 | data->set.upkeep_interval_ms = arg; |
3025 | 0 | break; |
3026 | 0 | case CURLOPT_MAXAGE_CONN: |
3027 | 0 | arg = va_arg(param, long); |
3028 | 0 | if(arg < 0) |
3029 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
3030 | 0 | data->set.maxage_conn = arg; |
3031 | 0 | break; |
3032 | 0 | case CURLOPT_MAXLIFETIME_CONN: |
3033 | 0 | arg = va_arg(param, long); |
3034 | 0 | if(arg < 0) |
3035 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
3036 | 0 | data->set.maxlifetime_conn = arg; |
3037 | 0 | break; |
3038 | 0 | case CURLOPT_TRAILERFUNCTION: |
3039 | 0 | #ifndef CURL_DISABLE_HTTP |
3040 | 0 | data->set.trailer_callback = va_arg(param, curl_trailer_callback); |
3041 | 0 | #endif |
3042 | 0 | break; |
3043 | 0 | case CURLOPT_TRAILERDATA: |
3044 | 0 | #ifndef CURL_DISABLE_HTTP |
3045 | 0 | data->set.trailer_data = va_arg(param, void *); |
3046 | 0 | #endif |
3047 | 0 | break; |
3048 | | #ifndef CURL_DISABLE_HSTS |
3049 | | case CURLOPT_HSTSREADFUNCTION: |
3050 | | data->set.hsts_read = va_arg(param, curl_hstsread_callback); |
3051 | | break; |
3052 | | case CURLOPT_HSTSREADDATA: |
3053 | | data->set.hsts_read_userp = va_arg(param, void *); |
3054 | | break; |
3055 | | case CURLOPT_HSTSWRITEFUNCTION: |
3056 | | data->set.hsts_write = va_arg(param, curl_hstswrite_callback); |
3057 | | break; |
3058 | | case CURLOPT_HSTSWRITEDATA: |
3059 | | data->set.hsts_write_userp = va_arg(param, void *); |
3060 | | break; |
3061 | | case CURLOPT_HSTS: { |
3062 | | struct curl_slist *h; |
3063 | | if(!data->hsts) { |
3064 | | data->hsts = Curl_hsts_init(); |
3065 | | if(!data->hsts) |
3066 | | return CURLE_OUT_OF_MEMORY; |
3067 | | } |
3068 | | argptr = va_arg(param, char *); |
3069 | | if(argptr) { |
3070 | | result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr); |
3071 | | if(result) |
3072 | | return result; |
3073 | | /* this needs to build a list of file names to read from, so that it can |
3074 | | read them later, as we might get a shared HSTS handle to load them |
3075 | | into */ |
3076 | | h = curl_slist_append(data->set.hstslist, argptr); |
3077 | | if(!h) { |
3078 | | curl_slist_free_all(data->set.hstslist); |
3079 | | data->set.hstslist = NULL; |
3080 | | return CURLE_OUT_OF_MEMORY; |
3081 | | } |
3082 | | data->set.hstslist = h; /* store the list for later use */ |
3083 | | } |
3084 | | else { |
3085 | | /* clear the list of HSTS files */ |
3086 | | curl_slist_free_all(data->set.hstslist); |
3087 | | data->set.hstslist = NULL; |
3088 | | if(!data->share || !data->share->hsts) |
3089 | | /* throw away the HSTS cache unless shared */ |
3090 | | Curl_hsts_cleanup(&data->hsts); |
3091 | | } |
3092 | | break; |
3093 | | } |
3094 | | case CURLOPT_HSTS_CTRL: |
3095 | | arg = va_arg(param, long); |
3096 | | if(arg & CURLHSTS_ENABLE) { |
3097 | | if(!data->hsts) { |
3098 | | data->hsts = Curl_hsts_init(); |
3099 | | if(!data->hsts) |
3100 | | return CURLE_OUT_OF_MEMORY; |
3101 | | } |
3102 | | } |
3103 | | else |
3104 | | Curl_hsts_cleanup(&data->hsts); |
3105 | | break; |
3106 | | #endif |
3107 | 0 | #ifndef CURL_DISABLE_ALTSVC |
3108 | 690 | case CURLOPT_ALTSVC: |
3109 | 690 | if(!data->asi) { |
3110 | 690 | data->asi = Curl_altsvc_init(); |
3111 | 690 | if(!data->asi) |
3112 | 0 | return CURLE_OUT_OF_MEMORY; |
3113 | 690 | } |
3114 | 690 | argptr = va_arg(param, char *); |
3115 | 690 | result = Curl_setstropt(&data->set.str[STRING_ALTSVC], argptr); |
3116 | 690 | if(result) |
3117 | 0 | return result; |
3118 | 690 | if(argptr) |
3119 | 690 | (void)Curl_altsvc_load(data->asi, argptr); |
3120 | 690 | break; |
3121 | 0 | case CURLOPT_ALTSVC_CTRL: |
3122 | 0 | if(!data->asi) { |
3123 | 0 | data->asi = Curl_altsvc_init(); |
3124 | 0 | if(!data->asi) |
3125 | 0 | return CURLE_OUT_OF_MEMORY; |
3126 | 0 | } |
3127 | 0 | arg = va_arg(param, long); |
3128 | 0 | result = Curl_altsvc_ctrl(data->asi, arg); |
3129 | 0 | if(result) |
3130 | 0 | return result; |
3131 | 0 | break; |
3132 | 0 | #endif |
3133 | 0 | case CURLOPT_PREREQFUNCTION: |
3134 | 0 | data->set.fprereq = va_arg(param, curl_prereq_callback); |
3135 | 0 | break; |
3136 | 0 | case CURLOPT_PREREQDATA: |
3137 | 0 | data->set.prereq_userp = va_arg(param, void *); |
3138 | 0 | break; |
3139 | 0 | #ifdef USE_WEBSOCKETS |
3140 | 4 | case CURLOPT_WS_OPTIONS: { |
3141 | 4 | bool raw; |
3142 | 4 | arg = va_arg(param, long); |
3143 | 4 | raw = (arg & CURLWS_RAW_MODE); |
3144 | 4 | data->set.ws_raw_mode = raw; |
3145 | 4 | break; |
3146 | 0 | } |
3147 | 0 | #endif |
3148 | 0 | case CURLOPT_QUICK_EXIT: |
3149 | 0 | data->set.quick_exit = (0 != va_arg(param, long)) ? 1L:0L; |
3150 | 0 | break; |
3151 | 693 | default: |
3152 | | /* unknown tag and its companion, just ignore: */ |
3153 | 693 | result = CURLE_UNKNOWN_OPTION; |
3154 | 693 | break; |
3155 | 8.28k | } |
3156 | | |
3157 | 8.16k | return result; |
3158 | 8.28k | } |
3159 | | |
3160 | | /* |
3161 | | * curl_easy_setopt() is the external interface for setting options on an |
3162 | | * easy handle. |
3163 | | * |
3164 | | * NOTE: This is one of few API functions that are allowed to be called from |
3165 | | * within a callback. |
3166 | | */ |
3167 | | |
3168 | | #undef curl_easy_setopt |
3169 | | CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...) |
3170 | 8.28k | { |
3171 | 8.28k | va_list arg; |
3172 | 8.28k | CURLcode result; |
3173 | | |
3174 | 8.28k | if(!data) |
3175 | 0 | return CURLE_BAD_FUNCTION_ARGUMENT; |
3176 | | |
3177 | 8.28k | va_start(arg, tag); |
3178 | | |
3179 | 8.28k | result = Curl_vsetopt(data, tag, arg); |
3180 | | |
3181 | 8.28k | va_end(arg); |
3182 | 8.28k | return result; |
3183 | 8.28k | } |