summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-06 19:39:59 +0200
committerSven Nierlein <sven@nierlein.de>2018-10-22 16:30:31 +0200
commit00cb1408adf1725ee05c1fe928c9207b7acc235b (patch)
tree45e8777b36517a637f74b281afd8ac91740652f8
parenta739a5614834178ba88d04972b4f4ba9c560e1df (diff)
downloadmonitoring-plugins-00cb1408adf1725ee05c1fe928c9207b7acc235b.tar.gz
fixed redirect sticky port handling in redir
-rw-r--r--.travis.yml3
-rw-r--r--configure.ac1
-rw-r--r--plugins/check_curl.c22
3 files changed, 14 insertions, 12 deletions
diff --git a/.travis.yml b/.travis.yml
index 617c4154..b8249aa7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,7 +20,7 @@ matrix:
20 name: "monitoring-plugins/monitoring-plugins" 20 name: "monitoring-plugins/monitoring-plugins"
21 description: "Monitoring Plugins" 21 description: "Monitoring Plugins"
22 notification_email: team@monitoring-plugins.org 22 notification_email: team@monitoring-plugins.org
23 build_command_prepend: tools/setup && ./configure 23 build_command_prepend: tools/setup && ./configure --enable-check-curl
24 build_command: make 24 build_command: make
25 branch_pattern: coverity.* 25 branch_pattern: coverity.*
26 - compiler: "clang" 26 - compiler: "clang"
@@ -55,6 +55,7 @@ install:
55 - sudo apt-get install -qq --no-install-recommends autoconf automake 55 - sudo apt-get install -qq --no-install-recommends autoconf automake
56 - sudo apt-get install -qq --no-install-recommends faketime 56 - sudo apt-get install -qq --no-install-recommends faketime
57 - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl 57 - sudo apt-get install -qq --no-install-recommends libmonitoring-plugin-perl
58 - sudo apt-get install -qq --no-install-recommends libcurl3-gnutls-dev
58 # Trusty related dependencies (not yet provided) 59 # Trusty related dependencies (not yet provided)
59 - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server 60 - test "$(dpkg -l | grep -E "mysql-(client|server)-[0-9].[0-9]" | grep -c ^ii)" -gt 0 || sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server
60 # enable ssl apache 61 # enable ssl apache
diff --git a/configure.ac b/configure.ac
index c56163c1..2291c51b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1908,5 +1908,6 @@ ACX_FEATURE([enable],[perl-modules])
1908ACX_FEATURE([with],[cgiurl]) 1908ACX_FEATURE([with],[cgiurl])
1909ACX_FEATURE([with],[trusted-path]) 1909ACX_FEATURE([with],[trusted-path])
1910ACX_FEATURE([enable],[libtap]) 1910ACX_FEATURE([enable],[libtap])
1911ACX_FEATURE([enable],[check-curl])
1911ACX_FEATURE([with],[libcurl]) 1912ACX_FEATURE([with],[libcurl])
1912 1913
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 72db27ad..3ae1c4d0 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -551,7 +551,7 @@ check_http (void)
551 CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size? 551 CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size?
552 */ 552 */
553 } else { 553 } else {
554 // old style redirection is handled below 554 /* old style redirection is handled below */
555 } 555 }
556 } 556 }
557 557
@@ -1019,6 +1019,8 @@ redir (curlhelp_write_curlbuf* header_buf)
1019 new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE)); 1019 new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
1020 } 1020 }
1021 1021
1022 /* compose new path */
1023 /* TODO: handle fragments and query part of URL */
1022 new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE); 1024 new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE);
1023 if (uri.pathHead) { 1025 if (uri.pathHead) {
1024 const UriPathSegmentA* p = uri.pathHead; 1026 const UriPathSegmentA* p = uri.pathHead;
@@ -1038,23 +1040,21 @@ redir (curlhelp_write_curlbuf* header_buf)
1038 1040
1039 /* set new values for redirected request */ 1041 /* set new values for redirected request */
1040 1042
1041 free (host_name);
1042 host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1043 free(new_host);
1044
1045 server_port = (unsigned short)new_port;
1046
1047 /* reset virtual port */
1048 virtual_port = server_port;
1049
1050 if (!(followsticky & STICKY_HOST)) { 1043 if (!(followsticky & STICKY_HOST)) {
1051 free (server_address); 1044 free (server_address);
1052 server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH); 1045 server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1053 } 1046 }
1054 if (!(followsticky & STICKY_PORT)) { 1047 if (!(followsticky & STICKY_PORT)) {
1055 server_port = new_port; 1048 server_port = (unsigned short)new_port;
1056 } 1049 }
1057 1050
1051 free (host_name);
1052 host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1053
1054 /* reset virtual port */
1055 virtual_port = server_port;
1056
1057 free(new_host);
1058 free (server_url); 1058 free (server_url);
1059 server_url = new_url; 1059 server_url = new_url;
1060 1060