diff options
author | Sven Nierlein <sven@nierlein.de> | 2020-05-18 12:08:45 (GMT) |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2020-05-18 12:08:45 (GMT) |
commit | 772fb233b92d4ad5fc87f30a8efee5c9bb295d1d (patch) | |
tree | 04a87c488f5eb1d13c1a59abb2eafda518226b20 /plugins | |
parent | 7d2582deb36d5bc1dd961be83bedc1e8fc8cb3c7 (diff) | |
download | monitoring-plugins-772fb233b92d4ad5fc87f30a8efee5c9bb295d1d.tar.gz |
check_curl: host_name may be nullrefs/pull/1535/head
for example when using like: ./check_curl localhost
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_curl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 2b0e378..2d69b31 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -127,8 +127,8 @@ int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; | |||
127 | int errcode; | 127 | int errcode; |
128 | int invert_regex = 0; | 128 | int invert_regex = 0; |
129 | 129 | ||
130 | char *server_address; | 130 | char *server_address = NULL; |
131 | char *host_name; | 131 | char *host_name = NULL; |
132 | char *server_url = 0; | 132 | char *server_url = 0; |
133 | char server_ip[DEFAULT_BUFFER_SIZE]; | 133 | char server_ip[DEFAULT_BUFFER_SIZE]; |
134 | struct curl_slist *server_ips = NULL; | 134 | struct curl_slist *server_ips = NULL; |
@@ -367,7 +367,7 @@ check_http (void) | |||
367 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_TIMEOUT, socket_timeout), "CURLOPT_TIMEOUT"); | 367 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_TIMEOUT, socket_timeout), "CURLOPT_TIMEOUT"); |
368 | 368 | ||
369 | // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy | 369 | // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy |
370 | if(use_ssl) { | 370 | if(use_ssl && host_name != NULL) { |
371 | struct curl_slist *host = NULL; | 371 | struct curl_slist *host = NULL; |
372 | char dnscache[DEFAULT_BUFFER_SIZE]; | 372 | char dnscache[DEFAULT_BUFFER_SIZE]; |
373 | snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, server_address); | 373 | snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, server_address); |
@@ -380,7 +380,7 @@ check_http (void) | |||
380 | /* compose URL: use the address we want to connect to, set Host: header later */ | 380 | /* compose URL: use the address we want to connect to, set Host: header later */ |
381 | snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", | 381 | snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", |
382 | use_ssl ? "https" : "http", | 382 | use_ssl ? "https" : "http", |
383 | use_ssl ? host_name : server_address, | 383 | use_ssl & host_name != NULL ? host_name : server_address, |
384 | server_port, | 384 | server_port, |
385 | server_url | 385 | server_url |
386 | ); | 386 | ); |