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