From 772fb233b92d4ad5fc87f30a8efee5c9bb295d1d Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 18 May 2020 14:08:45 +0200 Subject: check_curl: host_name may be null for example when using like: ./check_curl localhost 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; 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 ); -- cgit v0.10-9-g596f