aboutsummaryrefslogtreecommitdiff
path: root/lib/setopt.c
diff options
context:
space:
mode:
authortmilburn <thomas2@instantsolve.net>2019-03-07 20:23:54 +0000
committerDaniel Stenberg <daniel@haxx.se>2019-04-13 11:18:55 +0200
commitc3e38a4250d5f21a9189c3fdbbe45fbb71242184 (patch)
treed63321693aeacf22bd24847ceef8d08785f6dfec /lib/setopt.c
parentd715d2ac89abc0fc98ccb220c7f7cc148e747144 (diff)
CURLOPT_ADDRESS_SCOPE: fix range check and more
Commit 9081014 fixed most of the confusing issues between scope id and scope however 844896d added bad limits checking assuming that the scope is being set and not the scope id. I have fixed the documentation so it all refers to scope ids. In addition Curl_if2ip refered to the scope id as remote_scope_id which is incorrect, so I renamed it to local_scope_id. Adjusted-by: Daniel Stenberg Closes #3655 Closes #3765 Fixes #3713
Diffstat (limited to 'lib/setopt.c')
-rw-r--r--lib/setopt.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/setopt.c b/lib/setopt.c
index 6e596fa66..1df38fbb4 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -118,6 +118,7 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,
char *argptr;
CURLcode result = CURLE_OK;
long arg;
+ unsigned long uarg;
curl_off_t bigsize;
switch(option) {
@@ -2297,14 +2298,16 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,
case CURLOPT_ADDRESS_SCOPE:
/*
- * We always get longs when passed plain numericals, but for this value we
- * know that an unsigned int will always hold the value so we blindly
- * typecast to this type
+ * Use this scope id when using IPv6
+ * We always get longs when passed plain numericals so we should check
+ * that the value fits into an unsigned 32 bit integer.
*/
- arg = va_arg(param, long);
- if((arg < 0) || (arg > 0xf))
+ uarg = va_arg(param, unsigned long);
+#if SIZEOF_LONG > 4
+ if(uarg > UINT_MAX)
return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.scope_id = curlx_sltoui(arg);
+#endif
+ data->set.scope_id = (unsigned int)uarg;
break;
case CURLOPT_PROTOCOLS: