aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.de> 2020-05-18 14:08:45 +0200
committerGravatar Sven Nierlein <sven@nierlein.de> 2020-05-18 14:08:45 +0200
commit772fb233b92d4ad5fc87f30a8efee5c9bb295d1d (patch)
tree04a87c488f5eb1d13c1a59abb2eafda518226b20
parent7d2582deb36d5bc1dd961be83bedc1e8fc8cb3c7 (diff)
downloadmonitoring-plugins-772fb233b92d4ad5fc87f30a8efee5c9bb295d1d.tar.gz
check_curl: host_name may be null
for example when using like: ./check_curl localhost
-rw-r--r--plugins/check_curl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 2b0e3783..2d69b310 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -127,8 +127,8 @@ int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
int errcode;
int invert_regex = 0;
-char *server_address;
-char *host_name;
+char *server_address = NULL;
+char *host_name = NULL;
char *server_url = 0;
char server_ip[DEFAULT_BUFFER_SIZE];
struct curl_slist *server_ips = NULL;
@@ -367,7 +367,7 @@ check_http (void)
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_TIMEOUT, socket_timeout), "CURLOPT_TIMEOUT");
// 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
- if(use_ssl) {
+ if(use_ssl && host_name != NULL) {
struct curl_slist *host = NULL;
char dnscache[DEFAULT_BUFFER_SIZE];
snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, server_address);
@@ -380,7 +380,7 @@ check_http (void)
/* compose URL: use the address we want to connect to, set Host: header later */
snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
use_ssl ? "https" : "http",
- use_ssl ? host_name : server_address,
+ use_ssl & host_name != NULL ? host_name : server_address,
server_port,
server_url
);