summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c10
-rw-r--r--plugins/check_curl.d/check_curl_helpers.c14
-rw-r--r--plugins/check_curl.d/check_curl_helpers.h4
3 files changed, 20 insertions, 8 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index ba856a11..e3e514ff 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -69,10 +69,6 @@ const char *email = "devel@monitoring-plugins.org";
69#include <netdb.h> 69#include <netdb.h>
70 70
71enum { 71enum {
72 MAX_IPV4_HOSTLENGTH = 255,
73};
74
75enum {
76 REGS = 2, 72 REGS = 2,
77}; 73};
78 74
@@ -789,21 +785,21 @@ redir_wrapper redir(curlhelp_write_curlbuf *header_buf, const check_curl_config
789 /* set new values for redirected request */ 785 /* set new values for redirected request */
790 786
791 if (!(config.followsticky & STICKY_HOST)) { 787 if (!(config.followsticky & STICKY_HOST)) {
792 free(working_state.server_address); 788 // free(working_state.server_address);
793 working_state.server_address = strndup(new_host, MAX_IPV4_HOSTLENGTH); 789 working_state.server_address = strndup(new_host, MAX_IPV4_HOSTLENGTH);
794 } 790 }
795 if (!(config.followsticky & STICKY_PORT)) { 791 if (!(config.followsticky & STICKY_PORT)) {
796 working_state.serverPort = (unsigned short)new_port; 792 working_state.serverPort = (unsigned short)new_port;
797 } 793 }
798 794
799 free(working_state.host_name); 795 // free(working_state.host_name);
800 working_state.host_name = strndup(new_host, MAX_IPV4_HOSTLENGTH); 796 working_state.host_name = strndup(new_host, MAX_IPV4_HOSTLENGTH);
801 797
802 /* reset virtual port */ 798 /* reset virtual port */
803 working_state.virtualPort = working_state.serverPort; 799 working_state.virtualPort = working_state.serverPort;
804 800
805 free(new_host); 801 free(new_host);
806 free(working_state.server_url); 802 // free(working_state.server_url);
807 working_state.server_url = new_url; 803 working_state.server_url = new_url;
808 804
809 uriFreeUriMembersA(&uri); 805 uriFreeUriMembersA(&uri);
diff --git a/plugins/check_curl.d/check_curl_helpers.c b/plugins/check_curl.d/check_curl_helpers.c
index d49d8f07..e4e7bef6 100644
--- a/plugins/check_curl.d/check_curl_helpers.c
+++ b/plugins/check_curl.d/check_curl_helpers.c
@@ -128,8 +128,20 @@ check_curl_configure_curl(const check_curl_static_curl_config config,
128 char dnscache[DEFAULT_BUFFER_SIZE]; 128 char dnscache[DEFAULT_BUFFER_SIZE];
129 char addrstr[DEFAULT_BUFFER_SIZE / 2]; 129 char addrstr[DEFAULT_BUFFER_SIZE / 2];
130 if (working_state.use_ssl && working_state.host_name != NULL) { 130 if (working_state.use_ssl && working_state.host_name != NULL) {
131 char *tmp_mod_address;
132
133 /* lookup_host() requires an IPv6 address without the brackets. */
134 if ((strnlen(working_state.server_address, MAX_IPV4_HOSTLENGTH) > 2) &&
135 (working_state.server_address[0] == '[')) {
136 // Duplicate and strip the leading '['
137 tmp_mod_address =
138 strndup(working_state.server_address + 1, strlen(working_state.server_address) - 2);
139 } else {
140 tmp_mod_address = working_state.server_address;
141 }
142
131 int res; 143 int res;
132 if ((res = lookup_host(working_state.server_address, addrstr, DEFAULT_BUFFER_SIZE / 2, 144 if ((res = lookup_host(tmp_mod_address, addrstr, DEFAULT_BUFFER_SIZE / 2,
133 config.sin_family)) != 0) { 145 config.sin_family)) != 0) {
134 die(STATE_CRITICAL, 146 die(STATE_CRITICAL,
135 _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), 147 _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
diff --git a/plugins/check_curl.d/check_curl_helpers.h b/plugins/check_curl.d/check_curl_helpers.h
index 87e45a9d..e7b80f7e 100644
--- a/plugins/check_curl.d/check_curl_helpers.h
+++ b/plugins/check_curl.d/check_curl_helpers.h
@@ -7,6 +7,10 @@
7# include <openssl/opensslv.h> 7# include <openssl/opensslv.h>
8#endif 8#endif
9 9
10enum {
11 MAX_IPV4_HOSTLENGTH = 255,
12};
13
10/* for buffers for header and body */ 14/* for buffers for header and body */
11typedef struct { 15typedef struct {
12 size_t buflen; 16 size_t buflen;