From 2872cb7e6ac12ea356b943cf8f0b243c96b384f0 Mon Sep 17 00:00:00 2001 From: Kjell Schubert Date: Fri, 17 Apr 2015 13:08:19 -0700 Subject: [PATCH] test: regression test for incomplete/corrupted hdr Add regression test that verifies that old bugs regarding corrupted and incomplete headers are fixed. (D512233 + D570451, orig authors brianp@fb.com + jtarnawski@fb.com) PR-URL: https://github.com/joyent/http-parser/pull/236 Reviewed-By: Fedor Indutny --- test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test.c b/test.c index 58c1955..4328254 100644 --- a/test.c +++ b/test.c @@ -3619,6 +3619,22 @@ main (void) "\r\n"; test_simple(dumbfuck2, HPE_OK); + const char *corrupted_connection = + "GET / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Connection\r\033\065\325eep-Alive\r\n" + "Accept-Encoding: gzip\r\n" + "\r\n"; + test_simple(corrupted_connection, HPE_INVALID_HEADER_TOKEN); + + const char *corrupted_header_name = + "GET / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "X-Some-Header\r\033\065\325eep-Alive\r\n" + "Accept-Encoding: gzip\r\n" + "\r\n"; + test_simple(corrupted_header_name, HPE_INVALID_HEADER_TOKEN); + #if 0 // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body // until EOF.