]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not leak RedirectStateData on snprintf error/truncation (#2205)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Tue, 9 Sep 2025 09:45:48 +0000 (09:45 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Wed, 10 Sep 2025 01:53:13 +0000 (13:53 +1200)
src/redirect.cc

index 3ed07c1a75cc976e0183bc0c8e33ed94c9d3af7f..c24877f26788f2a2260df783a2cfcf64a7096b59 100644 (file)
@@ -230,20 +230,13 @@ constructHelperQuery(const char * const name, const Helper::Client::Pointer &hlp
     int sz;
     Http::StatusCode status;
 
-    /** TODO: create a standalone method to initialize
-     * the RedirectStateData for all the helpers.
-     */
-    RedirectStateData *r = new RedirectStateData(http->uri);
-    r->handler = handler;
-    r->data = cbdataReference(data);
-
     static MemBuf requestExtras;
     requestExtras.reset();
     if (requestExtrasFmt)
         requestExtrasFmt->assemble(requestExtras, http->al, 0);
 
     sz = snprintf(buf, MAX_REDIRECTOR_REQUEST_STRLEN, "%s%s%s\n",
-                  r->orig_url.c_str(),
+                  http->uri,
                   requestExtras.hasContent() ? " " : "",
                   requestExtras.hasContent() ? requestExtras.content() : "");
 
@@ -276,6 +269,13 @@ constructHelperQuery(const char * const name, const Helper::Client::Pointer &hlp
         return;
     }
 
+    /** TODO: create a standalone method to initialize
+     * the RedirectStateData for all the helpers.
+     */
+    const auto r = new RedirectStateData(http->uri);
+    r->handler = handler;
+    r->data = cbdataReference(data);
+
     debugs(61,6, "sending '" << buf << "' to the " << name << " helper");
     helperSubmit(hlp, buf, replyHandler, r);
 }