From: Alex Rousskov Date: Thu, 19 Nov 2015 05:08:41 +0000 (-0800) Subject: Stop using dangling pointers for eCAP-set custom HTTP reason phrases. X-Git-Tag: SQUID_3_5_12~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ce592c667421cbe204e7083849bc1c1510fc499;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 5bc8294675..dd3f059267 100644 --- a/src/adaptation/ecap/MessageRep.cc +++ b/src/adaptation/ecap/MessageRep.cc @@ -308,9 +308,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 cc74a3114a..9097fc0cfa 100644 --- a/src/http/StatusLine.h +++ b/src/http/StatusLine.h @@ -34,9 +34,12 @@ public: void clean(); /// 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 Http::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL); + /// reset the reason phrase to its default status code-derived value + void resetReason() { reason_ = NULL; } + /// retrieve the status code for this status line Http::StatusCode status() const { return status_; }