------------------------------------------------------------ revno: 13029 revision-id: squid3@treenet.co.nz-20131119224502-xfjih7weot5vp4gy parent: squid3@treenet.co.nz-20131118112919-ekes8rptw9m1qwmq committer: Amos Jeffries branch nick: 3.4 timestamp: Tue 2013-11-19 15:45:02 -0700 message: Make HTTP header parser obey relaxed_header_parser Some unimportant warnings were not obeying the directives silent/loud setting values. This abstracts the condition to simplify code and make all the non-critical warnings depend on the directive for their display level. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20131119224502-xfjih7weot5vp4gy # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.4 # testament_sha1: 2285d5e13d69b11c8e2664e3e6f9ebe897e22c1b # timestamp: 2013-11-19 22:52:12 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.4 # base_revision_id: squid3@treenet.co.nz-20131118112919-\ # ekes8rptw9m1qwmq # # Begin patch === modified file 'src/HttpHeader.cc' --- src/HttpHeader.cc 2013-08-08 06:08:37 +0000 +++ src/HttpHeader.cc 2013-11-19 22:45:02 +0000 @@ -549,6 +549,7 @@ { const char *field_ptr = header_start; HttpHeaderEntry *e, *e2; + bool warnOnError = (Config.onoff.relaxed_header_parser <= 0 ? DBG_IMPORTANT : 2); PROF_start(HttpHeaderParse); @@ -590,7 +591,7 @@ cr_only = false; } if (cr_only) { - debugs(55, DBG_IMPORTANT, "WARNING: Rejecting HTTP request with a CR+ " + debugs(55, DBG_IMPORTANT, "SECURITY WARNING: Rejecting HTTP request with a CR+ " "header field to prevent request smuggling attacks: {" << getStringPrefix(header_start, header_end) << "}"); goto reset; @@ -600,7 +601,7 @@ /* Barf on stray CR characters */ if (memchr(this_line, '\r', field_end - this_line)) { - debugs(55, DBG_IMPORTANT, "WARNING: suspicious CR characters in HTTP header {" << + debugs(55, warnOnError, "WARNING: suspicious CR characters in HTTP header {" << getStringPrefix(field_start, field_end) << "}"); if (Config.onoff.relaxed_header_parser) { @@ -615,7 +616,7 @@ } if (this_line + 1 == field_end && this_line > field_start) { - debugs(55, DBG_IMPORTANT, "WARNING: Blank continuation line in HTTP header {" << + debugs(55, warnOnError, "WARNING: Blank continuation line in HTTP header {" << getStringPrefix(header_start, header_end) << "}"); goto reset; } @@ -623,7 +624,7 @@ if (field_start == field_end) { if (field_ptr < header_end) { - debugs(55, DBG_IMPORTANT, "WARNING: unparseable HTTP header field near {" << + debugs(55, warnOnError, "WARNING: unparseable HTTP header field near {" << getStringPrefix(field_start, header_end) << "}"); goto reset; } @@ -632,23 +633,21 @@ } if ((e = HttpHeaderEntry::parse(field_start, field_end)) == NULL) { - debugs(55, DBG_IMPORTANT, "WARNING: unparseable HTTP header field {" << + debugs(55, warnOnError, "WARNING: unparseable HTTP header field {" << getStringPrefix(field_start, field_end) << "}"); - debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, - " in {" << getStringPrefix(header_start, header_end) << "}"); + debugs(55, warnOnError, " in {" << getStringPrefix(header_start, header_end) << "}"); if (Config.onoff.relaxed_header_parser) continue; - else - goto reset; + + goto reset; } if (e->id == HDR_CONTENT_LENGTH && (e2 = findEntry(e->id)) != NULL) { -// if (e->value.cmp(e2->value.termedBuf()) != 0) { if (e->value != e2->value) { int64_t l1, l2; - debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, - "WARNING: found two conflicting content-length headers in {" << getStringPrefix(header_start, header_end) << "}"); + debugs(55, warnOnError, "WARNING: found two conflicting content-length headers in {" << + getStringPrefix(header_start, header_end) << "}"); if (!Config.onoff.relaxed_header_parser) { delete e; @@ -669,22 +668,18 @@ continue; } } else { - debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, - "NOTICE: found double content-length header"); + debugs(55, warnOnError, "NOTICE: found double content-length header"); + delete e; - if (Config.onoff.relaxed_header_parser) { - delete e; + if (Config.onoff.relaxed_header_parser) continue; - } else { - delete e; - goto reset; - } + + goto reset; } } if (e->id == HDR_OTHER && stringHasWhitespace(e->name.termedBuf())) { - debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, - "WARNING: found whitespace in HTTP header name {" << + debugs(55, warnOnError, "WARNING: found whitespace in HTTP header name {" << getStringPrefix(field_start, field_end) << "}"); if (!Config.onoff.relaxed_header_parser) {