]> 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)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 9 Sep 2025 12:58:09 +0000 (12:58 +0000)
src/redirect.cc

index 54ba83c854fc973c4050186d28ccff44b9325bba..7a3d1ba2256ced33fccec218f39656c10fcc2c3e 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);
 }