Changeset 4558:8865fd1f3aa5 in nginx


Ignore:
Timestamp:
03/27/12 16:42:34 (8 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Phase:
public
Convert:
svn:c3fe7df1-7212-e011-8a91-001109144009/trunk@4559
Message:

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.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/http/ngx_http_variables.c

    r4545 r4558  
    12741274    ngx_http_variable_value_t *v, uintptr_t data)
    12751275{
     1276    u_char                    *real;
    12761277    size_t                     len;
    12771278    ngx_str_t                  path;
    12781279    ngx_http_core_loc_conf_t  *clcf;
    1279     u_char                     real[NGX_MAX_PATH];
     1280#if (NGX_HAVE_MAX_PATH)
     1281    u_char                     buffer[NGX_MAX_PATH];
     1282#endif
    12801283
    12811284    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
     
    12991302    }
    13001303
    1301     if (ngx_realpath(path.data, real) == NULL) {
     1304#if (NGX_HAVE_MAX_PATH)
     1305    real = buffer;
     1306#else
     1307    real = NULL;
     1308#endif
     1309
     1310    real = ngx_realpath(path.data, real);
     1311
     1312    if (real == NULL) {
    13021313        ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
    13031314                      ngx_realpath_n " \"%s\" failed", path.data);
     
    13091320    v->data = ngx_pnalloc(r->pool, len);
    13101321    if (v->data == NULL) {
     1322#if !(NGX_HAVE_MAX_PATH)
     1323        ngx_free(real);
     1324#endif
    13111325        return NGX_ERROR;
    13121326    }
     
    13181332
    13191333    ngx_memcpy(v->data, real, len);
     1334
     1335#if !(NGX_HAVE_MAX_PATH)
     1336    ngx_free(real);
     1337#endif
    13201338
    13211339    return NGX_OK;
  • src/os/unix/ngx_files.h

    r4498 r4558  
    201201
    202202
    203 #define ngx_realpath(p, r)       realpath((char *) p, (char *) r)
     203#define ngx_realpath(p, r)       (u_char *) realpath((char *) p, (char *) r)
    204204#define ngx_realpath_n           "realpath()"
    205205#define ngx_getcwd(buf, size)    (getcwd((char *) buf, size) != NULL)
     
    207207#define ngx_path_separator(c)    ((c) == '/')
    208208
     209
     210#if defined(PATH_MAX)
     211
     212#define NGX_HAVE_MAX_PATH        1
    209213#define NGX_MAX_PATH             PATH_MAX
     214
     215#else
     216
     217#define NGX_MAX_PATH             4096
     218
     219#endif
     220
    210221
    211222#define NGX_DIR_MASK_LEN         0
  • src/os/win32/ngx_files.h

    r4412 r4558  
    184184#define ngx_path_separator(c)       ((c) == '/' || (c) == '\\')
    185185
     186#define NGX_HAVE_MAX_PATH           1
    186187#define NGX_MAX_PATH                MAX_PATH
    187188
Note: See TracChangeset for help on using the changeset viewer.