]> 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>
Thu, 19 Nov 2015 05:08:41 +0000 (21:08 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 19 Nov 2015 05:08:41 +0000 (21:08 -0800)
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 5bc829467528f2ac62159f0ea7e3022577d66552..dd3f059267fea849ab12cadf4e3d5e459e62c232 100644 (file)
@@ -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
index cc74a3114a0adff37bcd3a0f4935f99339340cb0..9097fc0cfa4601c213a359422baeeded727c86ce 100644 (file)
@@ -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_; }