]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Stop using dangling pointers for eCAP-set custom HTTP reason phrases.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 15 Nov 2015 17:54:58 +0000 (10:54 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Sun, 15 Nov 2015 17:54:58 +0000 (10:54 -0700)
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").

src/adaptation/ecap/MessageRep.cc
src/http/StatusLine.h

index 9011dfd02e64e96e5995cf1dd60e6c37b1a1c934..812b94f9996456cbec7218b55a82c022627ebcb8 100644 (file)
@@ -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
index c34c76fa1a5bf30c2549fd29fb7c6e9288dbe859..54611d38409a4be7d865831d945279ca85e08363 100644 (file)
@@ -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_; }