]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed "Invalid read of size 1" bug in non-standard HTTP header search.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 5 Oct 2016 04:24:28 +0000 (22:24 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 5 Oct 2016 04:24:28 +0000 (22:24 -0600)
Valgrind error report:
Invalid read of size 1
   at strcasecmp
   by String::caseCmp(char const*) const
   by HttpHeader::getByNameIfPresent(char const*, int, String&)
   by HttpHeader::getByNameIfPresent(SBuf const&, String&)
   by HttpHeader::getByName(SBuf const&) const
   by assembleVaryKey(String&, SBuf&, HttpRequest const&)
   ...

The bug is probably not specific to Vary assembly and may have been
present since r14285 (gperf perfect hash refactoring).

src/HttpHeader.cc

index 0197509c23e101c998714fef401012ea190471c5..e1ebf4bb08ded650fd81915bb6bfbcc2687ec3d4 100644 (file)
@@ -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) == 0) {
+        if (e->id == Http::HdrType::OTHER && e->name.caseCmp(name, namelen) == 0) {
             found = true;
             strListAdd(&result, e->value.termedBuf(), ',');
         }