Let the HTTP client close the connection within an incomplete header
authorbluhm <bluhm@openbsd.org>
Mon, 27 Apr 2015 20:01:59 +0000 (20:01 +0000)
committerbluhm <bluhm@openbsd.org>
Mon, 27 Apr 2015 20:01:59 +0000 (20:01 +0000)
line.  Check that the session in relayd gets closes and it does not
result in a file descriptor leak.
Bug in relayd found by claudio@.

regress/usr.sbin/relayd/args-http-headline-close.pl [new file with mode: 0644]
regress/usr.sbin/relayd/args-https-headline-close.pl [new file with mode: 0644]

diff --git a/regress/usr.sbin/relayd/args-http-headline-close.pl b/regress/usr.sbin/relayd/args-http-headline-close.pl
new file mode 100644 (file)
index 0000000..3e86e0c
--- /dev/null
@@ -0,0 +1,30 @@
+# test http connection over http relay
+# The client writes an incomplete header line and closes the connection.
+# Check that the relay establishes and also closes the session.
+
+use strict;
+use warnings;
+
+our %args = (
+    client => {
+       func => sub {
+           print "GET ";  # missing new line
+       },
+       nocheck => 1,
+    },
+    relayd => {
+       protocol => [ "http",
+           "match request header log foo",
+           "match response header log bar",
+       ],
+       loggrep => {
+           qr/session 1 .*, done/ => 1,
+       },
+    },
+    server => {
+       noserver => 1,
+       nocheck => 1,
+    },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-https-headline-close.pl b/regress/usr.sbin/relayd/args-https-headline-close.pl
new file mode 100644 (file)
index 0000000..9ae14f0
--- /dev/null
@@ -0,0 +1,34 @@
+# test https connection over http relay
+# The client writes an incomplete header line and closes the connection.
+# Check that the relay establishes and also closes the session.
+
+use strict;
+use warnings;
+
+our %args = (
+    client => {
+       func => sub {
+           print "GET ";  # missing new line
+       },
+       ssl => 1,
+       nocheck => 1,
+    },
+    relayd => {
+       protocol => [ "http",
+           "match request header log foo",
+           "match response header log bar",
+       ],
+       forwardssl => 1,
+       listenssl => 1,
+       loggrep => {
+           qr/session 1 established/ => 1,
+           qr/session 1 .*, done/ => 1,
+       },
+    },
+    server => {
+       noserver => 1,
+       nocheck => 1,
+    },
+);
+
+1;