Klaus Demo nginx / 36aef0c
Fixed unconditional MAX_PATH usage (ticket #22). POSIX doesn't require it to be defined, and Debian GNU/Hurd doesn't define it. Note that if there is no MAX_PATH defined we have to use realpath() with NULL argument and free() the result. Maxim Dounin 10 years ago
3 changed file(s) with 33 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
12721272 ngx_http_variable_realpath_root(ngx_http_request_t *r,
12731273 ngx_http_variable_value_t *v, uintptr_t data)
12741274 {
1275 u_char *real;
12751276 size_t len;
12761277 ngx_str_t path;
12771278 ngx_http_core_loc_conf_t *clcf;
1278 u_char real[NGX_MAX_PATH];
1279 #if (NGX_HAVE_MAX_PATH)
1280 u_char buffer[NGX_MAX_PATH];
1281 #endif
12791282
12801283 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
12811284
12971300 }
12981301 }
12991302
1300 if (ngx_realpath(path.data, real) == NULL) {
1303 #if (NGX_HAVE_MAX_PATH)
1304 real = buffer;
1305 #else
1306 real = NULL;
1307 #endif
1308
1309 real = ngx_realpath(path.data, real);
1310
1311 if (real == NULL) {
13011312 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
13021313 ngx_realpath_n " \"%s\" failed", path.data);
13031314 return NGX_ERROR;
13071318
13081319 v->data = ngx_pnalloc(r->pool, len);
13091320 if (v->data == NULL) {
1321 #if !(NGX_HAVE_MAX_PATH)
1322 ngx_free(real);
1323 #endif
13101324 return NGX_ERROR;
13111325 }
13121326
13161330 v->not_found = 0;
13171331
13181332 ngx_memcpy(v->data, real, len);
1333
1334 #if !(NGX_HAVE_MAX_PATH)
1335 ngx_free(real);
1336 #endif
13191337
13201338 return NGX_OK;
13211339 }
199199 #endif
200200
201201
202 #define ngx_realpath(p, r) realpath((char *) p, (char *) r)
202 #define ngx_realpath(p, r) (u_char *) realpath((char *) p, (char *) r)
203203 #define ngx_realpath_n "realpath()"
204204 #define ngx_getcwd(buf, size) (getcwd((char *) buf, size) != NULL)
205205 #define ngx_getcwd_n "getcwd()"
206206 #define ngx_path_separator(c) ((c) == '/')
207207
208
209 #if defined(PATH_MAX)
210
211 #define NGX_HAVE_MAX_PATH 1
208212 #define NGX_MAX_PATH PATH_MAX
213
214 #else
215
216 #define NGX_MAX_PATH 4096
217
218 #endif
219
209220
210221 #define NGX_DIR_MASK_LEN 0
211222
182182 #define ngx_getcwd_n "GetCurrentDirectory()"
183183 #define ngx_path_separator(c) ((c) == '/' || (c) == '\\')
184184
185 #define NGX_HAVE_MAX_PATH 1
185186 #define NGX_MAX_PATH MAX_PATH
186187
187188 #define NGX_DIR_MASK (u_char *) "/*"