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 2018/05/08 10:53:20 UTC

[trafficserver] branch master updated: Changes the check on toPath, which will be NULL when there is no path

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 919f92f  Changes the check on toPath, which will be NULL when there is no path
919f92f is described below

commit 919f92fc05c3cb0dfc7c4c8ad6802fabe9045c2b
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon May 7 15:23:13 2018 +0100

    Changes the check on toPath, which will be NULL when there is no path
---
 proxy/http/remap/UrlRewrite.cc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index ef06863..cc0a47f 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -281,10 +281,8 @@ url_rewrite_remap_request(const UrlMappingContainer &mapping_container, URL *req
     toPath      = map_to->path_get(&toPathLen);
     requestPath = request_url->path_get(&requestPathLen);
 
-    // Should be +3, little extra padding won't hurt. Use the stack allocation
-    // for better performance (bummer that arrays of variable length is not supported
-    // on Solaris CC.
-    char *newPath  = static_cast<char *>(alloca(sizeof(char) * ((requestPathLen - fromPathLen) + toPathLen + 8)));
+    // Should be +3, little extra padding won't hurt.
+    char newPath[(requestPathLen - fromPathLen) + toPathLen + 8];
     int newPathLen = 0;
 
     *newPath = 0;
@@ -303,11 +301,11 @@ url_rewrite_remap_request(const UrlMappingContainer &mapping_container, URL *req
     if (requestPath) {
       // avoid adding another trailing slash if the requestPath already had one and so does the toPath
       if (requestPathLen < fromPathLen) {
-        if (toPathLen && requestPath[requestPathLen - 1] == '/' && toPath[toPathLen - 1] == '/') {
+        if (toPath && requestPath[requestPathLen - 1] == '/' && toPath[toPathLen - 1] == '/') {
           fromPathLen++;
         }
       } else {
-        if (toPathLen && requestPath[fromPathLen] == '/' && toPath[toPathLen - 1] == '/') {
+        if (toPath && requestPath[fromPathLen] == '/' && toPath[toPathLen - 1] == '/') {
           fromPathLen++;
         }
       }

-- 
To stop receiving notification emails like this one, please contact
zwoop@apache.org.