You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2018/06/05 12:33:21 UTC

svn commit: r1832934 - /httpd/httpd/trunk/modules/http2/h2_proxy_util.c

Author: icing
Date: Tue Jun  5 12:33:20 2018
New Revision: 1832934

URL: http://svn.apache.org/viewvc?rev=1832934&view=rev
Log:
Fixing h2 proxy link header mapping to substitute correctly again after r1831231 breakage.

Modified:
    httpd/httpd/trunk/modules/http2/h2_proxy_util.c

Modified: httpd/httpd/trunk/modules/http2/h2_proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_proxy_util.c?rev=1832934&r1=1832933&r2=1832934&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http2/h2_proxy_util.c (original)
+++ httpd/httpd/trunk/modules/http2/h2_proxy_util.c Tue Jun  5 12:33:20 2018
@@ -909,17 +909,17 @@ static size_t subst_str(link_ctx *ctx, i
 {
     int olen, nlen, plen;
     int delta;
-    char *s, *p;
+    char *p;
     
     olen = end - start;
     nlen = (int)strlen(ns);
     delta = nlen - olen;
     plen = ctx->slen + delta + 1;
-    s = apr_pcalloc(ctx->pool, plen);
-    p = apr_cpystrn(s, ctx->s, start);
-    p = apr_cpystrn(p, ns, nlen);
-    strcpy(p, ctx->s + end);
-    ctx->s = s;
+    p = apr_pcalloc(ctx->pool, plen);
+    memcpy(p, ctx->s, start);
+    memcpy(p + start, ns, nlen);
+    strcpy(p + start + nlen, ctx->s + end);
+    ctx->s = p;
     ctx->slen = (int)strlen(p);
     if (ctx->i >= end) {
         ctx->i += delta;
@@ -930,7 +930,7 @@ static size_t subst_str(link_ctx *ctx, i
 static void map_link(link_ctx *ctx) 
 {
     if (ctx->link_start < ctx->link_end) {
-        char buffer[HUGE_STRING_LEN], *p;
+        char buffer[HUGE_STRING_LEN];
         int need_len, link_len, buffer_len, prepend_p_server; 
         const char *mapped;
         
@@ -951,7 +951,9 @@ static void map_link(link_ctx *ctx)
                           "link_reverse_map uri too long, skipped: %s", ctx->s);
             return;
         }
-        apr_cpystrn(buffer + buffer_len, ctx->s + ctx->link_start, link_len);
+        strncpy(buffer + buffer_len, ctx->s + ctx->link_start, link_len);
+        buffer_len += link_len;
+        buffer[buffer_len] = '\0';
         if (!prepend_p_server
             && strcmp(ctx->real_backend_uri, ctx->p_server_uri)
             && !strncmp(buffer, ctx->real_backend_uri, ctx->rbu_len)) {
@@ -959,8 +961,10 @@ static void map_link(link_ctx *ctx)
              * to work, we need to use the proxy uri */
             int path_start = ctx->link_start + ctx->rbu_len;
             link_len -= ctx->rbu_len;
-            p = apr_cpystrn(buffer, ctx->p_server_uri, sizeof buffer);
-            apr_cpystrn(p, ctx->s + path_start, link_len);
+            strcpy(buffer, ctx->p_server_uri);
+            strncpy(buffer + ctx->psu_len, ctx->s + path_start, link_len);
+            buffer_len = ctx->psu_len + link_len;
+            buffer[buffer_len] = '\0';            
         }
         mapped = ap_proxy_location_reverse_map(ctx->r, ctx->conf, buffer);
         ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, ctx->r,