From: Joshua Rogers Date: Tue, 9 Sep 2025 09:45:48 +0000 (+0000) Subject: Do not leak RedirectStateData on snprintf error/truncation (#2205) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a66177665e2207d94205f77b420c3f91f0dd778e;p=thirdparty%2Fsquid.git Do not leak RedirectStateData on snprintf error/truncation (#2205) --- diff --git a/src/redirect.cc b/src/redirect.cc index 54ba83c854..7a3d1ba225 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -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); }