MCPcopy Create free account
hub / github.com/apache/httpd / ap_create_environment

Function ap_create_environment

server/util_script.c:112–966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
113{
114 const apr_array_header_t *env_arr = apr_table_elts(t);
115 const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
116 char **env = (char **) apr_palloc(p, (env_arr->nelts + 2) * sizeof(char *));
117 int i, j;
118 char *tz;
119 char *whack;
120
121 j = 0;
122 if (!apr_table_get(t, "TZ")) {
123 tz = getenv("TZ");
124 if (tz != NULL) {
125 env[j++] = apr_pstrcat(p, "TZ=", tz, NULL);
126 }
127 }
128 for (i = 0; i < env_arr->nelts; ++i) {
129 int changed = 0;
130
131 if (!elts[i].key) {
132 continue;
133 }
134 env[j] = apr_pstrcat(p, elts[i].key, "=", elts[i].val, NULL);
135 whack = env[j];
136 if (apr_isdigit(*whack)) {
137 *whack++ = '_';
138 changed = 1;
139 }
140 while (*whack != '=') {
141#ifdef WIN32
142 if (!apr_isalnum(*whack) && *whack != '_' && *whack != '(' && *whack != ')') {
143#else
144 if (!apr_isalnum(*whack) && *whack != '_') {
145#endif
146 *whack = '_';
147 changed = 1;
148 }
149 ++whack;
150 }
151 if (changed) {
152 *whack = '\0';
153 /*
154 * If after cleaning up the key the key is identical to an existing key
155 * in the table drop this environment variable. This also prevents
156 * to override CGI reserved environment variables with variables whose
157 * names have an invalid character instead of '_', but are otherwise
158 * equal to the names CGI reserved environment variables.
159 */
160 if (!apr_table_get(t, env[j])) {
161 ++j;
162 *whack = '=';
163 }
164 }
165 else {
166 ++j;
167 }
168 }
169

Callers 5

cgid_handlerFunction · 0.85
include_cmdFunction · 0.85
run_cgi_childFunction · 0.85
init_ext_filter_processFunction · 0.85
util_script.hFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected