[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 170/411: setopt: return CURLE_BAD_FUNCTION_ARGUMENT on bad argum
From: |
gnunet |
Subject: |
[gnurl] 170/411: setopt: return CURLE_BAD_FUNCTION_ARGUMENT on bad argument |
Date: |
Wed, 13 Jan 2021 01:19:45 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit a8e08a87dff8aeb91472c7064b8d19ca5c8ba318
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Mon Sep 21 23:27:21 2020 +0200
setopt: return CURLE_BAD_FUNCTION_ARGUMENT on bad argument
Fixed two return code mixups. CURLE_UNKNOWN_OPTION is saved for when the
option is, yeah, not known. Clarified this in the setopt man page too.
Closes #5993
---
docs/libcurl/curl_easy_setopt.3 | 3 +++
lib/setopt.c | 26 +++++++++-----------------
2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/docs/libcurl/curl_easy_setopt.3 b/docs/libcurl/curl_easy_setopt.3
index 666e65d98..362cfef0a 100644
--- a/docs/libcurl/curl_easy_setopt.3
+++ b/docs/libcurl/curl_easy_setopt.3
@@ -645,6 +645,9 @@ Strings passed on to libcurl must be shorter than 8000000
bytes, otherwise
\fIcurl_easy_setopt(3)\fP returns \fBCURLE_BAD_FUNCTION_ARGUMENT\fP (added in
7.65.0).
+\fBCURLE_BAD_FUNCTION_ARGUMENT\fP is returned when the argument to an option
+is invalid, like perhaps out of range.a
+
If you try to set an option that libcurl doesn't know about, perhaps because
the library is too old to support it or the option was removed in a recent
version, this function will return \fICURLE_UNKNOWN_OPTION\fP. If support for
diff --git a/lib/setopt.c b/lib/setopt.c
index a8f655b85..fa5398215 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -430,7 +430,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption
option, va_list param)
primary->version_max = version_max;
}
#else
- result = CURLE_UNKNOWN_OPTION;
+ result = CURLE_NOT_BUILT_IN;
#endif
break;
@@ -1077,7 +1077,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption
option, va_list param)
break;
default:
/* reserve other values for future use */
- result = CURLE_UNKNOWN_OPTION;
+ result = CURLE_BAD_FUNCTION_ARGUMENT;
break;
}
break;
@@ -1230,21 +1230,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data,
CURLoption option, va_list param)
* An FTP/SFTP option that modifies an upload to create missing
* directories on the server.
*/
- switch(va_arg(param, long)) {
- case 0:
- data->set.ftp_create_missing_dirs = 0;
- break;
- case 1:
- data->set.ftp_create_missing_dirs = 1;
- break;
- case 2:
- data->set.ftp_create_missing_dirs = 2;
- break;
- default:
- /* reserve other values for future use */
- result = CURLE_UNKNOWN_OPTION;
- break;
- }
+ arg = va_arg(param, long);
+ /* reserve other values for future use */
+ if((arg < CURLFTP_CREATE_DIR_NONE) ||
+ (arg > CURLFTP_CREATE_DIR_RETRY))
+ result = CURLE_BAD_FUNCTION_ARGUMENT;
+ else
+ data->set.ftp_create_missing_dirs = (int)arg;
break;
case CURLOPT_READDATA:
/*
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 112/411: travis: add a build using libressl (from git master), (continued)
- [gnurl] 112/411: travis: add a build using libressl (from git master), gnunet, 2021/01/12
- [gnurl] 131/411: imap: set cselect_bits to CURL_CSELECT_IN initially, gnunet, 2021/01/12
- [gnurl] 128/411: runtests: allow creating files without newlines, gnunet, 2021/01/12
- [gnurl] 147/411: TODO: add PR reference for native IDN support on macOS, gnunet, 2021/01/12
- [gnurl] 155/411: ftp: get rid of the PPSENDF macro, gnunet, 2021/01/12
- [gnurl] 167/411: parsedate: tune the date to epoch conversion, gnunet, 2021/01/12
- [gnurl] 146/411: tool_help.h: update copyright year range, gnunet, 2021/01/12
- [gnurl] 164/411: docs/MQTT: not experimental anymore, gnunet, 2021/01/12
- [gnurl] 178/411: dynbuf: make *addf() not require extra mallocs, gnunet, 2021/01/12
- [gnurl] 157/411: ftp: avoid risk of reading uninitialized integers, gnunet, 2021/01/12
- [gnurl] 170/411: setopt: return CURLE_BAD_FUNCTION_ARGUMENT on bad argument,
gnunet <=
- [gnurl] 185/411: strerror: honor Unicode API choice on Windows, gnunet, 2021/01/12
- [gnurl] 176/411: pingpong: remove a malloc per Curl_pp_vsendf call, gnunet, 2021/01/12
- [gnurl] 125/411: dynbuf: make sure Curl_dyn_tail() zero terminates, gnunet, 2021/01/12
- [gnurl] 144/411: tool_writeout: protect fputs() from NULL, gnunet, 2021/01/12
- [gnurl] 160/411: --help: strdup the category, gnunet, 2021/01/12
- [gnurl] 165/411: docs/MQTT: remove outdated paaragraphs, gnunet, 2021/01/12
- [gnurl] 175/411: symbian: drop support, gnunet, 2021/01/12
- [gnurl] 152/411: github: use new issue template feature, gnunet, 2021/01/12
- [gnurl] 171/411: http_proxy: do not count proxy headers in the header bytecount, gnunet, 2021/01/12
- [gnurl] 166/411: cmake: remove scary warning, gnunet, 2021/01/12