]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4852: regression in deny_info %R macro (#193)
authorAmos Jeffries <yadij@users.noreply.github.com>
Thu, 3 May 2018 15:52:04 +0000 (15:52 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Wed, 9 May 2018 10:23:29 +0000 (22:23 +1200)
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 0130629a54c157d7ece527f3cde19f966582b31a..fb4948b535e9edc25ff63373f42d057d75566ac8 100644 (file)
@@ -955,8 +955,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]";