From: Alex Rousskov Date: Sun, 15 Nov 2015 17:54:58 +0000 (-0700) Subject: Stop using dangling pointers for eCAP-set custom HTTP reason phrases. X-Git-Tag: SQUID_4_0_3~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65b0aca424a03509b53ccb7c707e40127c373997;p=thirdparty%2Fsquid.git Stop using dangling pointers for eCAP-set custom HTTP reason phrases. Squid still does not support [external] custom reason phrases and, hence, cannot reliably support eCAP API that sets the reason phrase to the one supplied by the adapter. This and r14398 changes fix [known] regression bugs introduced by r12728 ("SourceLayout"). --- diff --git a/src/adaptation/ecap/MessageRep.cc b/src/adaptation/ecap/MessageRep.cc index 9011dfd02e..812b94f999 100644 --- a/src/adaptation/ecap/MessageRep.cc +++ b/src/adaptation/ecap/MessageRep.cc @@ -301,9 +301,11 @@ Adaptation::Ecap::StatusLineRep::statusCode() const } void -Adaptation::Ecap::StatusLineRep::reasonPhrase(const Area &str) +Adaptation::Ecap::StatusLineRep::reasonPhrase(const Area &) { - theMessage.sline.set(theMessage.sline.version, theMessage.sline.status(), str.toString().c_str()); + // Squid does not support external custom reason phrases so we have + // to just reset it (in case there was a custom internal reason set) + theMessage.sline.resetReason(); } Adaptation::Ecap::StatusLineRep::Area diff --git a/src/http/StatusLine.h b/src/http/StatusLine.h index c34c76fa1a..54611d3840 100644 --- a/src/http/StatusLine.h +++ b/src/http/StatusLine.h @@ -35,8 +35,12 @@ public: /// set this status-line to the given values /// when reason is NULL the default message text for this StatusCode will be used + /// when reason is not NULL, it must not point to a dynamically allocated value void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL); + /// reset the reason phrase to its default status code-derived value + void resetReason() { reason_ = nullptr; } + /// retrieve the status code for this status line Http::StatusCode status() const { return status_; }