httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkal...@apache.org
Subject svn commit: r1643094 - /httpd/httpd/trunk/server/util_expr_eval.c
Date Mon, 15 Dec 2014 17:12:28 GMT
Author: jkaluza
Date: Wed Dec  3 11:10:50 2014
New Revision: 1643094

URL: http://svn.apache.org/r1643094
Log:
* ap_expr: Fix replace() func when length of "from" != length of "to".

Modified:
    httpd/httpd/trunk/server/util_expr_eval.c

Modified: httpd/httpd/trunk/server/util_expr_eval.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr_eval.c?rev=1643094&r1=1643093&r2=1643094&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr_eval.c (original)
+++ httpd/httpd/trunk/server/util_expr_eval.c Wed Dec  3 11:10:50 2014
@@ -194,7 +194,7 @@ static const char *ap_expr_eval_string_f
     if (arg->node_op == op_ListElement) {
         /* Evaluate the list elements and store them in apr_array_header. */
         ap_expr_string_list_func_t *func = (ap_expr_string_list_func_t *)info->node_arg1;
-        apr_array_header_t *args = apr_array_make(ctx->p, 1, sizeof(char *));
+        apr_array_header_t *args = apr_array_make(ctx->p, 2, sizeof(char *));
         do {
             const ap_expr_t *val = arg->node_arg1;
             const char **new = apr_array_push(args);
@@ -1130,7 +1130,7 @@ static const char *replace_func(ap_expr_
 {
     char *buff, *original, *replacement;
     struct ap_varbuf vb;
-    apr_size_t repl_len;
+    apr_size_t repl_len, orig_len;
     const char *repl;
     apr_size_t bytes;
     apr_size_t len;
@@ -1145,6 +1145,7 @@ static const char *replace_func(ap_expr_
     original = APR_ARRAY_IDX(args, 1, char *);
     replacement = APR_ARRAY_IDX(args, 0, char *);
     repl_len = strlen(replacement);
+    orig_len = strlen(original);
     bytes = strlen(buff);
 
     ap_varbuf_init(ctx->p, &vb, 0);
@@ -1155,7 +1156,7 @@ static const char *replace_func(ap_expr_
         ap_varbuf_strmemcat(&vb, buff, len);
         ap_varbuf_strmemcat(&vb, replacement, repl_len);
 
-        len += repl_len;
+        len += orig_len;
         bytes -= len;
         buff += len;
     }



Mime
View raw message