From 5cfc93d995cfd5cc7d1a469f3c1276c4884da2a2 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Thu, 11 Mar 2021 13:33:16 +0100 Subject: fix check_curl crash if http header contains leading spaces check_curl crashes when a (broken) http server returns invalid http header with leading spaces or double colons. This PR adds a fix and a test case for this. Signed-off-by: Sven Nierlein --- plugins/tests/check_curl.t | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'plugins/tests/check_curl.t') diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index 1afbe4bb..0caad23d 100755 --- a/plugins/tests/check_curl.t +++ b/plugins/tests/check_curl.t @@ -21,7 +21,7 @@ use FindBin qw($Bin); $ENV{'LC_TIME'} = "C"; -my $common_tests = 70; +my $common_tests = 72; my $ssl_only_tests = 8; # Check that all dependent modules are available eval "use HTTP::Daemon 6.01;"; @@ -188,6 +188,12 @@ sub run_server { $c->send_basic_header; $c->send_header('foo'); $c->send_crlf; + } elsif ($r->url->path eq "/header_broken_check") { + $c->send_basic_header; + $c->send_header('foo'); + print $c "Test1:: broken\n"; + print $c " Test2: leading whitespace\n"; + $c->send_crlf; } elsif ($r->url->path eq "/virtual_port") { # return sent Host header $c->send_basic_header; @@ -247,7 +253,7 @@ my $cmd; # advanced checks with virtual hostname and virtual port SKIP: { skip "libcurl version is smaller than $required_version", 6 unless $use_advanced_checks; - + # http without virtual port $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$port_http\$"; $result = NPTest->testCmd( $cmd ); @@ -259,7 +265,7 @@ SKIP: { $result = NPTest->testCmd( $cmd ); is( $result->return_code, 0, $cmd); like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); - + # http with virtual port (80) $cmd = "./$plugin -H $virtual_host:80 -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host\$"; $result = NPTest->testCmd( $cmd ); @@ -321,6 +327,10 @@ sub run_common_tests { is( $result->return_code, 2, "Missing header string check"); like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - header 'bar' not found on 'https?://127\.0\.0\.1:\d+/header_check'%, "Shows search string and location"); + $result = NPTest->testCmd( "$command -u /header_broken_check" ); + is( $result->return_code, 0, "header_check search for string"); + like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 138 bytes in [\d\.]+ second/', "Output correct" ); + my $cmd; $cmd = "$command -u /slow"; $result = NPTest->testCmd( $cmd ); -- cgit v1.2.3 From eb75d847ae31a86768b06926bc2323f7c16f07b9 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Thu, 20 May 2021 18:04:49 +0200 Subject: tests: increase startup sleep github action might fail from to time otherwise --- plugins/tests/check_curl.t | 5 +++-- plugins/tests/check_http.t | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins/tests/check_curl.t') diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index 0caad23d..29cb03f2 100755 --- a/plugins/tests/check_curl.t +++ b/plugins/tests/check_curl.t @@ -126,8 +126,6 @@ if ($pid) { exit; } } - # give our webservers some time to startup - sleep(1); } else { # Child #print "child\n"; @@ -140,6 +138,9 @@ if ($pid) { exit; } +# give our webservers some time to startup +sleep(3); + # Run the same server on http and https sub run_server { my $d = shift; diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index 2f051fad..0f56950f 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t @@ -102,8 +102,6 @@ if ($pid) { exit; } } - # give our webservers some time to startup - sleep(1); } else { # Child #print "child\n"; @@ -116,6 +114,9 @@ if ($pid) { exit; } +# give our webservers some time to startup +sleep(3); + # Run the same server on http and https sub run_server { my $d = shift; -- cgit v1.2.3