lib: survive some NULL input args

The input string pointer to:

curl_escape
curl_easy_escape
curl_unescape
curl_easy_unescape

The running_handles pointer to:

curl_multi_perform
curl_multi_socket_action
curl_multi_socket_all
curl_multi_socket

Reported-by: icy17 on github
Fixes #14247
Closes #14262
This commit is contained in:
Daniel Stenberg 2024-07-23 11:06:56 +02:00
parent 2a59c8d4ce
commit 0795014caa
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 6 additions and 4 deletions

View File

@ -60,7 +60,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
struct dynbuf d;
(void)data;
if(inlength < 0)
if(!string || (inlength < 0))
return NULL;
Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH * 3);
@ -181,7 +181,7 @@ char *curl_easy_unescape(struct Curl_easy *data, const char *string,
{
char *str = NULL;
(void)data;
if(length >= 0) {
if(string && (length >= 0)) {
size_t inputlen = (size_t)length;
size_t outputlen;
CURLcode res = Curl_urldecode(string, inputlen, &str, &outputlen,

View File

@ -2778,7 +2778,8 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
}
} while(t);
*running_handles = (int)multi->num_alive;
if(running_handles)
*running_handles = (int)multi->num_alive;
if(CURLM_OK >= returncode)
returncode = Curl_update_timer(multi);
@ -3302,7 +3303,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
if(first)
sigpipe_restore(&pipe_st);
*running_handles = (int)multi->num_alive;
if(running_handles)
*running_handles = (int)multi->num_alive;
return result;
}