diff options
| author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-11-08 02:32:03 +0000 |
|---|---|---|
| committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-11-08 02:32:03 +0000 |
| commit | 6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009 (patch) | |
| tree | ccc0cd52ce067193efecc1b4a05c9b86c5364a61 | |
| parent | 288b742ed61bb62a210fdd3614d4e3883aa82407 (diff) | |
| download | monitoring-plugins-6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009.tar.gz | |
Fixed bug where extra headers and redirect caused segfault (Dieter Van de Walle - 2089159)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2076 f882894a-f735-0410-b71e-b25c423dba1c
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | THANKS.in | 1 | ||||
| -rw-r--r-- | plugins/check_http.c | 4 | ||||
| -rwxr-xr-x | plugins/tests/check_http.t | 31 |
4 files changed, 34 insertions, 3 deletions
| @@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases. | |||
| 13 | Fixed segfault in extra-opts under some circumstance when reading multiple sections | 13 | Fixed segfault in extra-opts under some circumstance when reading multiple sections |
| 14 | Fix long options parsing in check_tcp | 14 | Fix long options parsing in check_tcp |
| 15 | check_icmp now reports min and max round trip time perfdata (Steve Rader) | 15 | check_icmp now reports min and max round trip time perfdata (Steve Rader) |
| 16 | Fixed bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159) | ||
| 16 | 17 | ||
| 17 | 1.4.13 25th Sept 2008 | 18 | 1.4.13 25th Sept 2008 |
| 18 | Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen) | 19 | Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen) |
| @@ -241,3 +241,4 @@ Erik Wasser | |||
| 241 | Tilman Koschnick | 241 | Tilman Koschnick |
| 242 | Olivier 'Babar' Raginel | 242 | Olivier 'Babar' Raginel |
| 243 | Steve Rader | 243 | Steve Rader |
| 244 | Dieter Van de Walle | ||
diff --git a/plugins/check_http.c b/plugins/check_http.c index df5daf2d..0746741c 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
| @@ -815,7 +815,9 @@ check_http (void) | |||
| 815 | for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) | 815 | for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) |
| 816 | asprintf (&buf, "%s%s\r\n", buf, pos); | 816 | asprintf (&buf, "%s%s\r\n", buf, pos); |
| 817 | } | 817 | } |
| 818 | free(http_opt_headers); | 818 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ |
| 819 | /* Covered in a testcase in tests/check_http.t */ | ||
| 820 | /* free(http_opt_headers); */ | ||
| 819 | } | 821 | } |
| 820 | 822 | ||
| 821 | /* optionally send the authentication info */ | 823 | /* optionally send the authentication info */ |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d54932e6..c5f90803 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
| @@ -28,7 +28,8 @@ if ($pid) { | |||
| 28 | #print "child\n"; | 28 | #print "child\n"; |
| 29 | 29 | ||
| 30 | my $d = HTTP::Daemon->new( | 30 | my $d = HTTP::Daemon->new( |
| 31 | LocalPort => $port | 31 | LocalPort => $port, |
| 32 | LocalAddr => "127.0.0.1", | ||
| 32 | ) || die; | 33 | ) || die; |
| 33 | print "Please contact me at: <URL:", $d->url, ">\n"; | 34 | print "Please contact me at: <URL:", $d->url, ">\n"; |
| 34 | while (my $c = $d->accept ) { | 35 | while (my $c = $d->accept ) { |
| @@ -57,6 +58,12 @@ if ($pid) { | |||
| 57 | $c->send_basic_header; | 58 | $c->send_basic_header; |
| 58 | $c->send_crlf; | 59 | $c->send_crlf; |
| 59 | $c->send_response($r->method.":".$r->content); | 60 | $c->send_response($r->method.":".$r->content); |
| 61 | } elsif ($r->url->path eq "/redirect") { | ||
| 62 | $c->send_redirect( "/redirect2" ); | ||
| 63 | } elsif ($r->url->path eq "/redirect2") { | ||
| 64 | $c->send_basic_header; | ||
| 65 | $c->send_crlf; | ||
| 66 | $c->send_response("redirected"); | ||
| 60 | } else { | 67 | } else { |
| 61 | $c->send_error(RC_FORBIDDEN); | 68 | $c->send_error(RC_FORBIDDEN); |
| 62 | } | 69 | } |
| @@ -73,7 +80,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
| 73 | } | 80 | } |
| 74 | 81 | ||
| 75 | if (-x "./check_http") { | 82 | if (-x "./check_http") { |
| 76 | plan tests => 39; | 83 | plan tests => 47; |
| 77 | } else { | 84 | } else { |
| 78 | plan skip_all => "No check_http compiled"; | 85 | plan skip_all => "No check_http compiled"; |
| 79 | } | 86 | } |
| @@ -180,3 +187,23 @@ $result = NPTest->testCmd( $cmd ); | |||
| 180 | is( $result->return_code, 0, $cmd); | 187 | is( $result->return_code, 0, $cmd); |
| 181 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output ); | 188 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output ); |
| 182 | 189 | ||
| 190 | $cmd = "$command -u /redirect"; | ||
| 191 | $result = NPTest->testCmd( $cmd ); | ||
| 192 | is( $result->return_code, 0, $cmd); | ||
| 193 | like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 194 | |||
| 195 | $cmd = "$command -f follow -u /redirect"; | ||
| 196 | $result = NPTest->testCmd( $cmd ); | ||
| 197 | is( $result->return_code, 0, $cmd); | ||
| 198 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 199 | |||
| 200 | $cmd = "$command -u /redirect -k 'follow: me'"; | ||
| 201 | $result = NPTest->testCmd( $cmd ); | ||
| 202 | is( $result->return_code, 0, $cmd); | ||
| 203 | like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 204 | |||
| 205 | $cmd = "$command -f follow -u /redirect -k 'follow: me'"; | ||
| 206 | $result = NPTest->testCmd( $cmd ); | ||
| 207 | is( $result->return_code, 0, $cmd); | ||
| 208 | like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 209 | |||
