]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4852: regression in deny_info %R macro (#193) M-staged-PR193
authorAmos Jeffries <yadij@users.noreply.github.com>
Thu, 3 May 2018 15:52:04 +0000 (15:52 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 3 May 2018 15:52:09 +0000 (15:52 +0000)
SBuf::c_str() produces a temporary c-string which is not
guaranteed to survive, and does not survive as long as required
to print the deny_info URL. The HttpRequest::url path SBuf has
a much longer lifetime, so use a const reference to it instead.

This was added in 51b5dcf59c93ef76fefacfeae837b076a624596e
along with many other identical uses which have since been
removed by other refactorings.

src/errorpage.cc

index c8fff43d177755849670b463fdf2abc8f9ee6973..233e7420668c51f929dfb7141e18dddfa845d3ca 100644 (file)
@@ -925,8 +925,8 @@ ErrorState::Convert(char token, bool building_deny_info_url, bool allowRecursion
     case 'R':
         if (building_deny_info_url) {
             if (request != NULL) {
-                SBuf tmp = request->url.path();
-                p = tmp.c_str();
+                const SBuf &tmp = request->url.path();
+                mb.append(tmp.rawContent(), tmp.length());
                 no_urlescape = 1;
             } else
                 p = "[no request]";