[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2076] nagiosplug/trunk

tonvoon at users.sourceforge.net tonvoon at users.sourceforge.net
Sat Nov 8 03:32:03 CET 2008


Revision: 2076
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2076&view=rev
Author:   tonvoon
Date:     2008-11-08 02:32:03 +0000 (Sat, 08 Nov 2008)

Log Message:
-----------
Fixed bug where extra headers and redirect caused segfault (Dieter Van de Walle - 2089159)

Modified Paths:
--------------
    nagiosplug/trunk/NEWS
    nagiosplug/trunk/THANKS.in
    nagiosplug/trunk/plugins/check_http.c
    nagiosplug/trunk/plugins/tests/check_http.t

Modified: nagiosplug/trunk/NEWS
===================================================================
--- nagiosplug/trunk/NEWS	2008-11-08 02:08:56 UTC (rev 2075)
+++ nagiosplug/trunk/NEWS	2008-11-08 02:32:03 UTC (rev 2076)
@@ -13,6 +13,7 @@
 	Fixed segfault in extra-opts under some circumstance when reading multiple sections
 	Fix long options parsing in check_tcp
 	check_icmp now reports min and max round trip time perfdata (Steve Rader)
+	Fixed bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159)
 
 1.4.13 25th Sept 2008
 	Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen)

Modified: nagiosplug/trunk/THANKS.in
===================================================================
--- nagiosplug/trunk/THANKS.in	2008-11-08 02:08:56 UTC (rev 2075)
+++ nagiosplug/trunk/THANKS.in	2008-11-08 02:32:03 UTC (rev 2076)
@@ -241,3 +241,4 @@
 Tilman Koschnick
 Olivier 'Babar' Raginel
 Steve Rader
+Dieter Van de Walle

Modified: nagiosplug/trunk/plugins/check_http.c
===================================================================
--- nagiosplug/trunk/plugins/check_http.c	2008-11-08 02:08:56 UTC (rev 2075)
+++ nagiosplug/trunk/plugins/check_http.c	2008-11-08 02:32:03 UTC (rev 2076)
@@ -815,7 +815,9 @@
       for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER)))
         asprintf (&buf, "%s%s\r\n", buf, pos);
     }
-    free(http_opt_headers);
+    /* This cannot be free'd here because a redirection will then try to access this and segfault */
+    /* Covered in a testcase in tests/check_http.t */
+    /* free(http_opt_headers); */
   }
 
   /* optionally send the authentication info */

Modified: nagiosplug/trunk/plugins/tests/check_http.t
===================================================================
--- nagiosplug/trunk/plugins/tests/check_http.t	2008-11-08 02:08:56 UTC (rev 2075)
+++ nagiosplug/trunk/plugins/tests/check_http.t	2008-11-08 02:32:03 UTC (rev 2076)
@@ -28,7 +28,8 @@
 	#print "child\n";
 
 	my $d = HTTP::Daemon->new(
-		LocalPort => $port
+		LocalPort => $port,
+		LocalAddr => "127.0.0.1",
 	) || die;
 	print "Please contact me at: <URL:", $d->url, ">\n";
 	while (my $c = $d->accept ) {
@@ -57,6 +58,12 @@
 				$c->send_basic_header;
 				$c->send_crlf;
 				$c->send_response($r->method.":".$r->content);
+			} elsif ($r->url->path eq "/redirect") {
+				$c->send_redirect( "/redirect2" );
+			} elsif ($r->url->path eq "/redirect2") {
+				$c->send_basic_header;
+				$c->send_crlf;
+				$c->send_response("redirected");
 			} else {
 				$c->send_error(RC_FORBIDDEN);
 			}
@@ -73,7 +80,7 @@
 }
 
 if (-x "./check_http") {
-	plan tests => 39;
+	plan tests => 47;
 } else {
 	plan skip_all => "No check_http compiled";
 }
@@ -180,3 +187,23 @@
 is( $result->return_code, 0, $cmd);
 like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output );
 
+$cmd = "$command -u /redirect";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -f follow -u /redirect";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -u /redirect -k 'follow: me'";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -f follow -u /redirect -k 'follow: me'";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list