From: Amos Jeffries Date: Thu, 6 Oct 2016 21:02:32 +0000 (+1300) Subject: Fix header name mismatching after rev.14870 X-Git-Tag: SQUID_4_0_15~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1997a487f7092b0fbbded4acffb07d2b8f6c9e3d;p=thirdparty%2Fsquid.git Fix header name mismatching after rev.14870 When a mime header set contains two custom headers and one name is the prefix for the other the name lookup using a fixed length for String comparison can wrongly match the longer header as being equal to the shorter one, since only the identical prefix portion is compared. To avoid this we must check that the lengths are also matching. This also improves performance very slightly as the common case for custom headers is to have an "X-" prefix which is slower to compare than total length. Headers having same length and same prefix is quite rare. --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index e1ebf4bb08..2191f91474 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -882,7 +882,7 @@ HttpHeader::getByNameIfPresent(const char *name, int namelen, String &result) co /* Sorry, an unknown header name. Do linear search */ bool found = false; while ((e = getEntry(&pos))) { - if (e->id == Http::HdrType::OTHER && e->name.caseCmp(name, namelen) == 0) { + if (e->id == Http::HdrType::OTHER && e->name.size() == static_cast(namelen) && e->name.caseCmp(name, namelen) == 0) { found = true; strListAdd(&result, e->value.termedBuf(), ','); }