From 94aff00568c70f0b2f5504275ad8513490a8b6ce Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 11 Dec 2018 14:16:13 +0000 Subject: [PATCH] Merge r1848236 from trunk: core: Fix incorrect substitution of env vars in directives containing multiple env vars. In ap_resolve_env(), the string returned from getenv() should be copied since the returned string may be statically allocated. This fixes an issue where the value for the last env var is substituted for all env vars in a directive containing multiple env vars. Submitted by: hwibell Reviewed by: hwibell, covener, jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1848686 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 7 ------- server/core.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 88e5320671b..a9b1d6bdf12 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ Changes with Apache 2.4.38 and we should just set the value for the environment variable like in the pattern case. [Christophe Jaillet] + *) core: Incorrect values for environment variables are substituted when + multiple environment variables are specified in a directive. [Hank Ibell] + *) mod_rewrite: Only create the global mutex used by "RewriteMap prg:" when this type of map is present in the configuration. PR62311. [Hank Ibell ] diff --git a/STATUS b/STATUS index 7ec7e620959..3c2c563b8e3 100644 --- a/STATUS +++ b/STATUS @@ -126,13 +126,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) core: Fix incorrect substitution of env vars in directives containing - multiple env vars. In ap_resolve_env(), the string returned from - getenv() should be copied since the returned string may be - statically allocated. - trunk patch: http://svn.apache.org/r1848236 - 2.4.x patch: svn merge -c 1848236 ^/httpd/httpd/trunk . - +1: hwibell, covener, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/server/core.c b/server/core.c index aa62e15267a..e2a91c7a0c6 100644 --- a/server/core.c +++ b/server/core.c @@ -1361,7 +1361,7 @@ AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word) if (server_config_defined_vars) word = apr_table_get(server_config_defined_vars, name); if (!word) - word = getenv(name); + word = apr_pstrdup(p, getenv(name)); if (word) { current->string = word; current->len = strlen(word); -- 2.47.3