TS-2316: header_rewrite: fixed segfaults in ConditionPath::append_value()

Submitted by: Manjesh Nilange <[email protected]>
Sponsored by: LinkedIn


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/236c52cf
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/236c52cf
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/236c52cf

Branch: refs/heads/5.0.x
Commit: 236c52cf2bb4d6831494fe4bddfba8b9acff68e3
Parents: 38b05cd
Author: Alexey Ivanov <[email protected]>
Authored: Sat Nov 2 21:08:17 2013 -0700
Committer: Alexey Ivanov <[email protected]>
Committed: Sun Nov 10 18:07:53 2013 -0800

----------------------------------------------------------------------
 plugins/header_rewrite/conditions.cc | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/236c52cf/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc 
b/plugins/header_rewrite/conditions.cc
index 40f92ef..17d1ad5 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -224,13 +224,19 @@ ConditionPath::initialize(Parser& p)
   _matcher = match;
 }
 
-void
-ConditionPath::append_value(std::string& s, const Resources& res)
-{
-  int path_len = 0;
-  const char *path = TSUrlPathGet(res._rri->requestBufp, res._rri->requestUrl, 
&path_len);
-  TSDebug(PLUGIN_NAME, "Appending PATH to evaluation value: %.*s", path_len, 
path);
-  s.append(path, path_len);
+void ConditionPath::append_value(std::string& s, const Resources& res) {
+  TSMBuffer bufp;
+  TSMLoc url_loc;
+
+  if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
+    int path_length;
+    const char *path = TSUrlPathGet(bufp, url_loc, &path_length);
+
+    if (path && path_length)
+      s.append(path, path_length);
+
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
+  }
 }
 
 bool

Reply via email to