]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4492: Handle SP padded size in chunked encoding
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 12 Apr 2016 15:07:13 +0000 (03:07 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 12 Apr 2016 15:07:13 +0000 (03:07 +1200)
src/http/one/Parser.cc
src/http/one/Parser.h
src/http/one/TeChunkedParser.cc

index 87f5f12a39c0231028a890326237d9552ea80635..2b9b63e6acb6cd930bd4b0a0e3ace315961ba4ef 100644 (file)
@@ -142,3 +142,10 @@ Http::One::Parser::getHeaderField(const char *name)
     return NULL;
 }
 
+#if USE_HTTP_VIOLATIONS
+int
+Http::One::Parser::violationLevel() const
+{
+    return Config.onoff.relaxed_header_parser < 0 ? DBG_IMPORTANT : 5;
+}
+#endif
index abe30a245cc3fbeafeaff319d3adbd344c3627df..dc57583e6e3529824d0e8144509a870ebabc1801 100644 (file)
@@ -91,6 +91,11 @@ public:
     /// the remaining unprocessed section of buffer
     const SBuf &remaining() const {return buf_;}
 
+#if USE_HTTP_VIOLATIONS
+    /// the right debugs() level for parsing HTTP violation messages
+    int violationLevel() const;
+#endif
+
     /**
      * HTTP status code resulting from the parse process.
      * to be used on the invalid message handling.
index 53a7afca194570e2bc16f3dbd8c4a70d5e062704..28a03db5f7824175b48ac90d0fe174730499aa11 100644 (file)
@@ -14,6 +14,7 @@
 #include "http/ProtocolVersion.h"
 #include "MemBuf.h"
 #include "Parsing.h"
+#include "SquidConfig.h"
 
 Http::One::TeChunkedParser::TeChunkedParser()
 {
@@ -90,6 +91,14 @@ Http::One::TeChunkedParser::parseChunkSize(Http1::Tokenizer &tok)
 
         theChunkSize = theLeftBodySize = size;
         debugs(94,7, "found chunk: " << theChunkSize);
+
+#if USE_HTTP_VIOLATIONS
+         // Bug 4492: IBM_HTTP_Server pads out to 4 bytes with SP characters
+        if (Config.onoff.relaxed_header_parser && tok.skipAll(CharacterSet::SP)) {
+            debugs(94, violationLevel(), "WARNING: skipped invalid whitespace in chunk size");
+        }
+#endif
+
         buf_ = tok.remaining(); // parse checkpoint
         parsingStage_ = Http1::HTTP_PARSE_CHUNK_EXT;
         return true;