1
diff -Nur httpd-2.0~/server/util.c httpd-2.0/server/util.c
2
--- httpd-2.0~/server/util.c
3
+++ build-tree/apache2/server/util.c
7
#if RESOLVE_ENV_PER_TOKEN
8
- return ap_resolve_env(p,result);
9
+ return (char *)ap_resolve_env(p,result);
15
AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word)
17
- char tmp[ MAX_STRING_LEN ];
21
- if (!(s=ap_strchr_c(word,'$')))
25
- /* XXX - relies on strncat() to add '\0'
27
- strncat(tmp,word,s - word);
28
- if ((s[1] == '{') && (e=ap_strchr_c(s,'}'))) {
32
- var = apr_pstrndup(p, s+2, e2-(s+2));
37
- strncat(tmp, s, e2-s);
41
- /* ignore invalid strings */
45
- } while ((s=ap_strchr_c(word,'$')));
47
+# define SMALL_EXPANSION 5
52
+ } *result, *current, sresult[SMALL_EXPANSION];
54
+ const char *s, *e, *ep;
58
+ s = ap_strchr_c(word, '$');
63
+ /* well, actually something to do */
64
+ ep = word + strlen(word);
66
+ result = current = &(sresult[spc++]);
67
+ current->next = NULL;
68
+ current->string = word;
69
+ current->len = s - word;
70
+ outlen = current->len;
73
+ /* prepare next entry */
75
+ current->next = (spc < SMALL_EXPANSION)
77
+ : (struct sll *)apr_palloc(p,
78
+ sizeof(*current->next));
79
+ current = current->next;
80
+ current->next = NULL;
84
- return apr_pstrdup(p,tmp);
86
+ if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
87
+ word = getenv(apr_pstrndup(p, s+2, e-s-2));
89
+ current->string = word;
90
+ current->len = strlen(word);
91
+ outlen += current->len;
94
+ current->string = s;
95
+ current->len = e - s + 1;
96
+ outlen += current->len;
101
+ current->string = s++;
108
+ s = ap_strchr_c(s, '$');
109
+ current->string = word;
110
+ current->len = s ? s - word : ep - word;
111
+ outlen += current->len;
115
+ /* assemble result */
116
+ res_buf = cp = apr_palloc(p, outlen + 1);
119
+ memcpy(cp, result->string, result->len);
122
+ result = result->next;
124
+ res_buf[outlen] = '\0';
129
AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp)