You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/08/06 04:35:24 UTC

[1/2] trafficserver git commit: TS-3658 ASAN triggers when using the escalate.so plugin

Repository: trafficserver
Updated Branches:
  refs/heads/master fe64607f2 -> 0c28aa665


TS-3658 ASAN triggers when using the escalate.so plugin


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

Branch: refs/heads/master
Commit: 9e8800c5f648e4902c522087e88d9ea806a1de4f
Parents: fe64607
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Aug 5 20:08:52 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Aug 5 20:08:56 2015 -0600

----------------------------------------------------------------------
 proxy/http/HttpSM.cc | 50 +++++++++++++++++++----------------------------
 1 file changed, 20 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e8800c5/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 9da84b5..8ba5eaa 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7527,38 +7527,33 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
 
     if (host != NULL) {
       int port = clientUrl.port_get();
-      char buf[host_len + 7];
-
       int redirectSchemeLen;
       const char *redirectScheme = clientUrl.scheme_get(&redirectSchemeLen);
+
       if (redirectScheme == NULL) {
         clientUrl.scheme_set(scheme_str, scheme_len);
-        DebugSM("http_redirect", "[HttpSM::redirect_request] hsot without scheme %s", buf);
+        DebugSM("http_redirect", "[HttpSM::redirect_request] URL without scheme %.*s", redirectSchemeLen, redirectScheme);
       }
 
       if (noPortInHost) {
         int redirectSchemeIdx = clientUrl.scheme_get_wksidx();
-
         bool defaultPort =
           (((redirectSchemeIdx == URL_WKSIDX_HTTP) && (port == 80)) || ((redirectSchemeIdx == URL_WKSIDX_HTTPS) && (port == 443)));
 
-        if (!defaultPort)
+        if (!defaultPort) {
           noPortInHost = false;
+        }
       }
 
-      ink_strlcpy(buf, host, host_len + 1);
-
       if (!noPortInHost) {
-        char port_buf[6]; // handle upto 5 digit port
-        buf[host_len++] = ':';
-        buf[host_len] = '\0';
+        char buf[host_len + 7]; // 5 + 1 + 1 ("12345" + ':' + '\0')
 
-        host_len += ink_small_itoa(port, port_buf, sizeof(port_buf));
-        ink_strlcat(buf, port_buf, sizeof(buf));
+        host_len = snprintf(buf, host_len + 7, "%.*s:%d", host_len, host, port);
+        t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, host_len);
+      } else {
+        t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, host, host_len);
       }
-
       t_state.hdr_info.client_request.m_target_cached = false;
-      t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, host_len);
     } else {
       // the client request didn't have a host, so use the current origin host
       if (valid_origHost) {
@@ -7566,18 +7561,15 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
 
         // the client request didn't have a host, so use the current origin host
         DebugSM("http_redirect", "[HttpSM::redirect_request] keeping client request host %s://%s", next_hop_scheme, origHost);
-        char *origHost1 = strtok_r(origHost, ":", &saveptr);
-        if (origHost1 == NULL) {
+        char *origHostNoPort = strtok_r(origHost, ":", &saveptr);
+
+        if (origHostNoPort == NULL) {
           goto LhostError;
         }
-        origHost_len = strlen(origHost1);
-        int origHostPort_len = origHost_len;
-        char buf[origHostPort_len + 7];
-        ink_strlcpy(buf, origHost1, origHost_len + 1);
 
+        host_len = strlen(origHostNoPort);
         if (noPortInHost) {
           int redirectSchemeIdx = t_state.next_hop_scheme;
-
           bool defaultPort = (((redirectSchemeIdx == URL_WKSIDX_HTTP) && (origPort == 80)) ||
                               ((redirectSchemeIdx == URL_WKSIDX_HTTPS) && (origPort == 443)));
 
@@ -7586,20 +7578,18 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
         }
 
         if (!noPortInHost) {
-          char port_buf[6]; // handle upto 5 digit port
-          buf[origHostPort_len++] = ':';
-          buf[origHostPort_len] = '\0';
-          origHostPort_len += ink_small_itoa(origPort, port_buf, sizeof(port_buf));
-          ink_strlcat(buf, port_buf, sizeof(buf));
+          char buf[host_len + 7]; // 5 + 1 + 1 ("12345" + ':' + '\0')
+
+          host_len = snprintf(buf, host_len + 7, "%s:%d", origHostNoPort, origPort);
+          t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, host_len);
+        } else {
+          t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, origHostNoPort, host_len);
         }
 
+        // Cleanup of state etc.
         url_nuke_proxy_stuff(clientUrl.m_url_impl);
         url_nuke_proxy_stuff(t_state.hdr_info.client_request.m_url_cached.m_url_impl);
         t_state.hdr_info.client_request.method_set(origMethod, origMethod_len);
-        if (noPortInHost)
-          t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, origHost_len);
-        else
-          t_state.hdr_info.client_request.value_set(MIME_FIELD_HOST, MIME_LEN_HOST, buf, origHostPort_len);
         t_state.hdr_info.client_request.m_target_cached = false;
         clientUrl.scheme_set(scheme_str, scheme_len);
       } else {


[2/2] trafficserver git commit: TS-3824 Fix #include of pcre for a couple of plugins

Posted by zw...@apache.org.
TS-3824 Fix #include of pcre for a couple of plugins


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

Branch: refs/heads/master
Commit: 0c28aa665ddf633171884a9ca0a90e89ade71ce5
Parents: 9e8800c
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Aug 5 20:18:09 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Aug 5 20:27:53 2015 -0600

----------------------------------------------------------------------
 plugins/experimental/geoip_acl/acl.h  | 5 +++++
 plugins/header_rewrite/regex_helper.h | 6 ++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c28aa66/plugins/experimental/geoip_acl/acl.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/acl.h b/plugins/experimental/geoip_acl/acl.h
index 81c35cf..e9be954 100644
--- a/plugins/experimental/geoip_acl/acl.h
+++ b/plugins/experimental/geoip_acl/acl.h
@@ -21,7 +21,12 @@
 
 #include <ts/ts.h>
 #include <ts/remap.h>
+
+#ifdef HAVE_PCRE_PCRE_H
+#include <pcre/pcre.h>
+#else
 #include <pcre.h>
+#endif
 
 #include <string>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c28aa66/plugins/header_rewrite/regex_helper.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/regex_helper.h b/plugins/header_rewrite/regex_helper.h
index 45b061c..6be153a 100644
--- a/plugins/header_rewrite/regex_helper.h
+++ b/plugins/header_rewrite/regex_helper.h
@@ -18,7 +18,13 @@
 #ifndef REGEX_HELPER_H
 #define REGEX_HELPER_H
 
+#include "ts/ink_defs.h"
+
+#ifdef HAVE_PCRE_PCRE_H
+#include <pcre/pcre.h>
+#else
 #include <pcre.h>
+#endif
 
 #include <string>