------------------------------------------------------------ revno: 14094 revision-id: squid3@treenet.co.nz-20161009123616-0yqg23ikkzt7mi44 parent: squidadm@squid-cache.org-20161009001414-pksjx5jduk9uf5t8 author: Alex Rousskov committer: Amos Jeffries branch nick: 3.5 timestamp: Mon 2016-10-10 01:36:16 +1300 message: Avoid segfaults when debugging section 4 at level 9. The bug was probably added in r11496. It was exposed by Valgrind's "Conditional jump or move depends on uninitialised value(s)" error. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20161009123616-0yqg23ikkzt7mi44 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 212d96c51a7ed1141eb0bdb7c01efae905c8e621 # timestamp: 2016-10-09 12:51:06 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squidadm@squid-cache.org-20161009001414-\ # pksjx5jduk9uf5t8 # # Begin patch === modified file 'src/errorpage.cc' --- src/errorpage.cc 2016-01-01 00:14:27 +0000 +++ src/errorpage.cc 2016-10-09 12:36:16 +0000 @@ -358,7 +358,6 @@ bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos) { while (pos < hdr.size()) { - char *dt = lang; /* skip any initial whitespace. */ while (pos < hdr.size() && xisspace(hdr[pos])) @@ -372,6 +371,7 @@ * with preference given to an exact match. */ bool invalid_byte = false; + char *dt = lang; while (pos < hdr.size() && hdr[pos] != ';' && hdr[pos] != ',' && !xisspace(hdr[pos]) && dt < (lang + (langLen -1)) ) { if (!invalid_byte) { #if USE_HTTP_VIOLATIONS @@ -391,7 +391,6 @@ ++pos; } *dt = '\0'; // nul-terminated the filename content string before system use. - ++dt; // if we terminated the tag on garbage or ';' we need to skip to the next ',' or end of header. while (pos < hdr.size() && hdr[pos] != ',') @@ -400,7 +399,7 @@ if (pos < hdr.size() && hdr[pos] == ',') ++pos; - debugs(4, 9, HERE << "STATE: dt='" << dt << "', lang='" << lang << "', pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'"); + debugs(4, 9, "STATE: lang=" << lang << ", pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'"); /* if we found anything we might use, try it. */ if (*lang != '\0' && !invalid_byte)