mirror of
https://github.com/curl/curl.git
synced 2025-02-17 14:59:45 +08:00
lib: add debug log outputs for CURLE_BAD_FUNCTION_ARGUMENT
Closes #12658
This commit is contained in:
parent
8e0323b4b5
commit
cfe7902111
@ -335,9 +335,6 @@ CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file)
|
|||||||
CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl)
|
CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(asi);
|
DEBUGASSERT(asi);
|
||||||
if(!ctrl)
|
|
||||||
/* unexpected */
|
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
||||||
asi->flags = ctrl;
|
asi->flags = ctrl;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
@ -858,6 +858,7 @@ CURLcode Curl_set_dns_servers(struct Curl_easy *data,
|
|||||||
case ARES_ENODATA:
|
case ARES_ENODATA:
|
||||||
case ARES_EBADSTR:
|
case ARES_EBADSTR:
|
||||||
default:
|
default:
|
||||||
|
DEBUGF(infof(data, "bad servers set"));
|
||||||
result = CURLE_BAD_FUNCTION_ARGUMENT;
|
result = CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -896,6 +897,7 @@ CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(Curl_inet_pton(AF_INET, local_ip4, &a4) != 1) {
|
if(Curl_inet_pton(AF_INET, local_ip4, &a4) != 1) {
|
||||||
|
DEBUGF(infof(data, "bad DNS IPv4 address"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -923,6 +925,7 @@ CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(Curl_inet_pton(AF_INET6, local_ip6, a6) != 1) {
|
if(Curl_inet_pton(AF_INET6, local_ip6, a6) != 1) {
|
||||||
|
DEBUGF(infof(data, "bad DNS IPv6 address"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,9 +688,9 @@ static CURLcode easy_transfer(struct Curl_multi *multi)
|
|||||||
/* Make sure to return some kind of error if there was a multi problem */
|
/* Make sure to return some kind of error if there was a multi problem */
|
||||||
if(mcode) {
|
if(mcode) {
|
||||||
result = (mcode == CURLM_OUT_OF_MEMORY) ? CURLE_OUT_OF_MEMORY :
|
result = (mcode == CURLM_OUT_OF_MEMORY) ? CURLE_OUT_OF_MEMORY :
|
||||||
/* The other multi errors should never happen, so return
|
/* The other multi errors should never happen, so return
|
||||||
something suitably generic */
|
something suitably generic */
|
||||||
CURLE_BAD_FUNCTION_ARGUMENT;
|
CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -185,7 +185,7 @@ struct curl_header *curl_easy_nextheader(CURL *easy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode namevalue(char *header, size_t hlen, unsigned int type,
|
static CURLcode namevalue(char *header, size_t hlen, unsigned int type,
|
||||||
char **name, char **value)
|
char **name, char **value)
|
||||||
{
|
{
|
||||||
char *end = header + hlen - 1; /* point to the last byte */
|
char *end = header + hlen - 1; /* point to the last byte */
|
||||||
DEBUGASSERT(hlen);
|
DEBUGASSERT(hlen);
|
||||||
@ -291,6 +291,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
|
|||||||
end = strchr(header, '\r');
|
end = strchr(header, '\r');
|
||||||
if(!end) {
|
if(!end) {
|
||||||
end = strchr(header, '\n');
|
end = strchr(header, '\n');
|
||||||
|
DEBUGASSERT(end);
|
||||||
if(!end)
|
if(!end)
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,7 @@ static CURLcode hsts_create(struct hsts *h,
|
|||||||
if(hlen && (hostname[hlen - 1] == '.'))
|
if(hlen && (hostname[hlen - 1] == '.'))
|
||||||
/* strip off any trailing dot */
|
/* strip off any trailing dot */
|
||||||
--hlen;
|
--hlen;
|
||||||
|
DEBUGASSERT(hlen);
|
||||||
if(!hlen)
|
if(!hlen)
|
||||||
/* no host name left */
|
/* no host name left */
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
@ -481,6 +482,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h)
|
|||||||
if(sc == CURLSTS_OK) {
|
if(sc == CURLSTS_OK) {
|
||||||
time_t expires;
|
time_t expires;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
DEBUGASSERT(e.name[0]);
|
||||||
if(!e.name[0])
|
if(!e.name[0])
|
||||||
/* bail out if no name was stored */
|
/* bail out if no name was stored */
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
@ -2095,6 +2095,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
|
|||||||
|
|
||||||
switch(data->set.timecondition) {
|
switch(data->set.timecondition) {
|
||||||
default:
|
default:
|
||||||
|
DEBUGF(infof(data, "invalid time condition"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
|
||||||
case CURL_TIMECOND_IFMODSINCE:
|
case CURL_TIMECOND_IFMODSINCE:
|
||||||
|
@ -75,8 +75,7 @@ static CURLcode ftpsend(struct Curl_easy *data, struct connectdata *conn,
|
|||||||
unsigned char data_sec = conn->data_prot;
|
unsigned char data_sec = conn->data_prot;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!cmd)
|
DEBUGASSERT(cmd);
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
||||||
|
|
||||||
write_len = strlen(cmd);
|
write_len = strlen(cmd);
|
||||||
if(!write_len || write_len > (sizeof(s) -3))
|
if(!write_len || write_len > (sizeof(s) -3))
|
||||||
|
@ -1236,6 +1236,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: /* Invalid kind: should not occur. */
|
default: /* Invalid kind: should not occur. */
|
||||||
|
DEBUGF(infof(data, "invalid MIMEKIND* attempt"));
|
||||||
res = CURLE_BAD_FUNCTION_ARGUMENT; /* Internal error? */
|
res = CURLE_BAD_FUNCTION_ARGUMENT; /* Internal error? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -524,8 +524,10 @@ static CURLcode mqtt_publish(struct Curl_easy *data)
|
|||||||
char encodedbytes[4];
|
char encodedbytes[4];
|
||||||
curl_off_t postfieldsize = data->set.postfieldsize;
|
curl_off_t postfieldsize = data->set.postfieldsize;
|
||||||
|
|
||||||
if(!payload)
|
if(!payload) {
|
||||||
|
DEBUGF(infof(data, "mqtt_publish without payload, return bad arg"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
if(postfieldsize < 0)
|
if(postfieldsize < 0)
|
||||||
payloadlen = strlen(payload);
|
payloadlen = strlen(payload);
|
||||||
else
|
else
|
||||||
|
@ -201,7 +201,7 @@ CURLcode Curl_rand(struct Curl_easy *data, unsigned char *rnd, size_t num)
|
|||||||
{
|
{
|
||||||
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
|
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
|
||||||
DEBUGASSERT(num > 0);
|
DEBUGASSERT(num);
|
||||||
|
|
||||||
while(num) {
|
while(num) {
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
@ -241,9 +241,11 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
|
|||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((num/2 >= sizeof(buffer)) || !(num&1))
|
if((num/2 >= sizeof(buffer)) || !(num&1)) {
|
||||||
/* make sure it fits in the local buffer and that it is an odd number! */
|
/* make sure it fits in the local buffer and that it is an odd number! */
|
||||||
|
DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
num--; /* save one for null-termination */
|
num--; /* save one for null-termination */
|
||||||
|
|
||||||
|
@ -3122,6 +3122,10 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
arg = va_arg(param, long);
|
arg = va_arg(param, long);
|
||||||
|
if(!arg) {
|
||||||
|
DEBUGF(infof(data, "bad CURLOPT_ALTSVC_CTRL input"));
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
result = Curl_altsvc_ctrl(data->asi, arg);
|
result = Curl_altsvc_ctrl(data->asi, arg);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
@ -3176,5 +3180,9 @@ CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
|
|||||||
result = Curl_vsetopt(data, tag, arg);
|
result = Curl_vsetopt(data, tag, arg);
|
||||||
|
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
#ifdef DEBUGBUILD
|
||||||
|
if(result == CURLE_BAD_FUNCTION_ARGUMENT)
|
||||||
|
infof(data, "setopt arg 0x%x returned CURLE_BAD_FUNCTION_ARGUMENT", tag);
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -799,8 +799,10 @@ static CURLcode check_telnet_options(struct Curl_easy *data)
|
|||||||
was given on the command line */
|
was given on the command line */
|
||||||
if(data->state.aptr.user) {
|
if(data->state.aptr.user) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
if(str_is_nonascii(data->conn->user))
|
if(str_is_nonascii(data->conn->user)) {
|
||||||
|
DEBUGF(infof(data, "set a non ASCII user name in telnet"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user);
|
msnprintf(buffer, sizeof(buffer), "USER,%s", data->conn->user);
|
||||||
beg = curl_slist_append(tn->telnet_vars, buffer);
|
beg = curl_slist_append(tn->telnet_vars, buffer);
|
||||||
if(!beg) {
|
if(!beg) {
|
||||||
|
5
lib/ws.c
5
lib/ws.c
@ -997,8 +997,11 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *data, const void *buffer,
|
|||||||
ws = data->conn->proto.ws;
|
ws = data->conn->proto.ws;
|
||||||
|
|
||||||
if(data->set.ws_raw_mode) {
|
if(data->set.ws_raw_mode) {
|
||||||
if(fragsize || flags)
|
if(fragsize || flags) {
|
||||||
|
DEBUGF(infof(data, "ws_send: "
|
||||||
|
"fragsize and flags cannot be non-zero in raw mode"));
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
if(!buflen)
|
if(!buflen)
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user