src/http/ngx_http_core_module.c:1321: error: Buffer Overrun L3
  Offset: [1, +oo] Size: [0, +oo] by call to `ngx_open_cached_file`.

src/http/ngx_http_core_module.c:1205:5: Assignment
1203.     name = NULL;
1204.     /* suppress MSVC warning */
1205.     path.data = NULL;
          ^
1206. 
1207.     tf = clcf->try_files;

src/http/ngx_http_core_module.c:1321:13: Call
1319.         }
1320. 
1321.         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
                  ^
1322.             != NGX_OK)
1323.         {

src/core/ngx_open_file_cache.c:139:1: Parameter `*name->data`
  137. 
  138. 
  139. ngx_int_t
       ^
  140. ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
  141.     ngx_open_file_info_t *of, ngx_pool_t *pool)

src/core/ngx_open_file_cache.c:159:17: Call
  157.         if (of->test_only) {
  158. 
  159.             if (ngx_file_info_wrapper(name, of, &fi, pool->log)
                       ^
  160.                 == NGX_FILE_ERROR)
  161.             {

src/core/ngx_open_file_cache.c:714:1: Parameter `*name->data`
    712. 
    713. 
    714. static ngx_int_t
         ^
    715. ngx_file_info_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,
    716.     ngx_file_info_t *fi, ngx_log_t *log)

src/core/ngx_open_file_cache.c:749:10: Call
    747.     }
    748. 
    749.     fd = ngx_open_file_wrapper(name, of, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
                  ^
    750.                                NGX_FILE_OPEN, 0, log);
    751. 

src/core/ngx_open_file_cache.c:547:1: <Length trace>
545. 
546. 
547. static ngx_fd_t
     ^
548. ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,
549.     ngx_int_t mode, ngx_int_t create, ngx_int_t access, ngx_log_t *log)

src/core/ngx_open_file_cache.c:547:1: Parameter `of->disable_symlinks_from`
      545. 
      546. 
      547. static ngx_fd_t
           ^
      548. ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,
      549.     ngx_int_t mode, ngx_int_t create, ngx_int_t access, ngx_log_t *log)

src/core/ngx_open_file_cache.c:590:9: Assignment
      588.     if (of->disable_symlinks_from) {
      589. 
      590.         cp = p + of->disable_symlinks_from;
                   ^
      591. 
      592.         *cp = '\0';

src/core/ngx_open_file_cache.c:592:9: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `ngx_open_cached_file` 
      590.         cp = p + of->disable_symlinks_from;
      591. 
      592.         *cp = '\0';
                   ^
      593. 
      594.         at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,

static ngx_fd_t
ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,
    ngx_int_t mode, ngx_int_t create, ngx_int_t access, ngx_log_t *log)
{
    ngx_fd_t  fd;
#if !(NGX_HAVE_OPENAT)
    fd = ngx_open_file(name->data, mode, create, access);
    if (fd == NGX_INVALID_FILE) {
        of->err = ngx_errno;
        of->failed = ngx_open_file_n;
        return NGX_INVALID_FILE;
    }
    return fd;
#else
    u_char           *p, *cp, *end;
    ngx_fd_t          at_fd;
    ngx_str_t         at_name;
    if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_OFF) {
        fd = ngx_open_file(name->data, mode, create, access);
        if (fd == NGX_INVALID_FILE) {
            of->err = ngx_errno;
            of->failed = ngx_open_file_n;
            return NGX_INVALID_FILE;
        }
        return fd;
    }
    p = name->data;
    end = p + name->len;
    at_name = *name;
    if (of->disable_symlinks_from) {
        cp = p + of->disable_symlinks_from;
        *cp = '\0';
        at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
                              NGX_FILE_OPEN, 0);
        *cp = '/';
        if (at_fd == NGX_INVALID_FILE) {
            of->err = ngx_errno;
            of->failed = ngx_open_file_n;
            return NGX_INVALID_FILE;
        }
        at_name.len = of->disable_symlinks_from;
        p = cp + 1;
    } else if (*p == '/') {
        at_fd = ngx_open_file("/",
                              NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
                              NGX_FILE_OPEN, 0);
        if (at_fd == NGX_INVALID_FILE) {
            of->err = ngx_errno;
            of->failed = ngx_openat_file_n;
            return NGX_INVALID_FILE;
        }
        at_name.len = 1;
        p++;
    } else {
        at_fd = NGX_AT_FDCWD;
    }
    for ( ;; ) {
        cp = ngx_strlchr(p, end, '/');
        if (cp == NULL) {
            break;
        }
        if (cp == p) {
            p++;
            continue;
        }
        *cp = '\0';
        if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER) {
            fd = ngx_openat_file_owner(at_fd, p,
                                       NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
                                       NGX_FILE_OPEN, 0, log);
        } else {
            fd = ngx_openat_file(at_fd, p,
                           NGX_FILE_SEARCH|NGX_FILE_NONBLOCK|NGX_FILE_NOFOLLOW,
                           NGX_FILE_OPEN, 0);
        }
        *cp = '/';
        if (fd == NGX_INVALID_FILE) {
            of->err = ngx_errno;
            of->failed = ngx_openat_file_n;
            goto failed;
        }
        if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) {
            ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
                          ngx_close_file_n " \"%V\" failed", &at_name);
        }
        p = cp + 1;
        at_fd = fd;
        at_name.len = cp - at_name.data;
    }
    if (p == end) {
        fd = ngx_openat_file(at_fd, ".", mode, create, access);
        goto done;
    }
    if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER
        && !(create & (NGX_FILE_CREATE_OR_OPEN|NGX_FILE_TRUNCATE)))
    {
        fd = ngx_openat_file_owner(at_fd, p, mode, create, access, log);
    } else {
        fd = ngx_openat_file(at_fd, p, mode|NGX_FILE_NOFOLLOW, create, access);
    }
done:
    if (fd == NGX_INVALID_FILE) {
        of->err = ngx_errno;
        of->failed = ngx_openat_file_n;
    }
failed:
    if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) {
        ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
                      ngx_close_file_n " \"%V\" failed", &at_name);
    }
    return fd;
#endif
}
['ngx_int_t\nngx_http_core_try_files_phase(ngx_http_request_t *r,\n    ngx_http_phase_handler_t *ph)\n{\n    size_t                        len, root, alias, reserve, allocated;\n    u_char                       *p, *name;\n    ngx_str_t                     path, args;\n    ngx_uint_t                    test_dir;\n    ngx_http_try_file_t          *tf;\n    ngx_open_file_info_t          of;\n    ngx_http_script_code_pt       code;\n    ngx_http_script_engine_t      e;\n    ngx_http_core_loc_conf_t     *clcf;\n    ngx_http_script_len_code_pt   lcode;\n    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                   "try files phase: %ui", r->phase_handler);\n    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);\n    if (clcf->try_files == NULL) {\n        r->phase_handler++;\n        return NGX_AGAIN;\n    }\n    allocated = 0;\n    root = 0;\n    name = NULL;\n    path.data = NULL;\n    tf = clcf->try_files;\n    alias = clcf->alias;\n    for ( ;; ) {\n        if (tf->lengths) {\n            ngx_memzero(&e, sizeof(ngx_http_script_engine_t));\n            e.ip = tf->lengths->elts;\n            e.request = r;\n            len = 1;\n            while (*(uintptr_t *) e.ip) {\n                lcode = *(ngx_http_script_len_code_pt *) e.ip;\n                len += lcode(&e);\n            }\n        } else {\n            len = tf->name.len;\n        }\n        reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;\n        if (reserve > allocated) {\n            if (ngx_http_map_uri_to_path(r, &path, &root, reserve) == NULL) {\n                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return NGX_OK;\n            }\n            name = path.data + root;\n            allocated = path.len - root - (r->uri.len - alias);\n         }\n        if (tf->values == NULL) {\n            ngx_memcpy(name, tf->name.data, tf->name.len);\n            path.len = (name + tf->name.len - 1) - path.data;\n        } else {\n            e.ip = tf->values->elts;\n            e.pos = name;\n            e.flushed = 1;\n            while (*(uintptr_t *) e.ip) {\n                code = *(ngx_http_script_code_pt *) e.ip;\n                code((ngx_http_script_engine_t *) &e);\n            }\n            path.len = e.pos - path.data;\n            *e.pos = \'\\0\';\n            if (alias && ngx_strncmp(name, clcf->name.data, alias) == 0) {\n                ngx_memmove(name, name + alias, len - alias);\n                path.len -= alias;\n            }\n        }\n        test_dir = tf->test_dir;\n        tf++;\n        ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "trying to use %s: \\"%s\\" \\"%s\\"",\n                       test_dir ? "dir" : "file", name, path.data);\n        if (tf->lengths == NULL && tf->name.len == 0) {\n            if (tf->code) {\n                ngx_http_finalize_request(r, tf->code);\n                return NGX_OK;\n            }\n            path.len -= root;\n            path.data += root;\n            if (path.data[0] == \'@\') {\n                (void) ngx_http_named_location(r, &path);\n            } else {\n                ngx_http_split_args(r, &path, &args);\n                (void) ngx_http_internal_redirect(r, &path, &args);\n            }\n            ngx_http_finalize_request(r, NGX_DONE);\n            return NGX_OK;\n        }\n        ngx_memzero(&of, sizeof(ngx_open_file_info_t));\n        of.read_ahead = clcf->read_ahead;\n        of.directio = clcf->directio;\n        of.valid = clcf->open_file_cache_valid;\n        of.min_uses = clcf->open_file_cache_min_uses;\n        of.test_only = 1;\n        of.errors = clcf->open_file_cache_errors;\n        of.events = clcf->open_file_cache_events;\n        if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {\n            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n            return NGX_OK;\n        }\n        if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)\n            != NGX_OK)\n        {\n            if (of.err != NGX_ENOENT\n                && of.err != NGX_ENOTDIR\n                && of.err != NGX_ENAMETOOLONG)\n            {\n                ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,\n                              "%s \\"%s\\" failed", of.failed, path.data);\n            }\n            continue;\n        }\n        if (of.is_dir && !test_dir) {\n            continue;\n        }\n        path.len -= root;\n        path.data += root;\n        if (!alias) {\n            r->uri = path;\n#if (NGX_PCRE)\n        } else if (clcf->regex) {\n            if (!test_dir) {\n                r->uri = path;\n                r->add_uri_to_alias = 1;\n            }\n#endif\n        } else {\n            r->uri.len = alias + path.len;\n            r->uri.data = ngx_pnalloc(r->pool, r->uri.len);\n            if (r->uri.data == NULL) {\n                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);\n                return NGX_OK;\n            }\n            p = ngx_copy(r->uri.data, clcf->name.data, alias);\n            ngx_memcpy(p, name, path.len);\n        }\n        ngx_http_set_exten(r);\n        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,\n                       "try file uri: \\"%V\\"", &r->uri);\n        r->phase_handler++;\n        return NGX_AGAIN;\n    }\n}', 'ngx_int_t\nngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,\n    ngx_open_file_info_t *of, ngx_pool_t *pool)\n{\n    time_t                          now;\n    uint32_t                        hash;\n    ngx_int_t                       rc;\n    ngx_file_info_t                 fi;\n    ngx_pool_cleanup_t             *cln;\n    ngx_cached_open_file_t         *file;\n    ngx_pool_cleanup_file_t        *clnf;\n    ngx_open_file_cache_cleanup_t  *ofcln;\n    of->fd = NGX_INVALID_FILE;\n    of->err = 0;\n    if (cache == NULL) {\n        if (of->test_only) {\n            if (ngx_file_info_wrapper(name, of, &fi, pool->log)\n                == NGX_FILE_ERROR)\n            {\n                return NGX_ERROR;\n            }\n            of->uniq = ngx_file_uniq(&fi);\n            of->mtime = ngx_file_mtime(&fi);\n            of->size = ngx_file_size(&fi);\n            of->fs_size = ngx_file_fs_size(&fi);\n            of->is_dir = ngx_is_dir(&fi);\n            of->is_file = ngx_is_file(&fi);\n            of->is_link = ngx_is_link(&fi);\n            of->is_exec = ngx_is_exec(&fi);\n            return NGX_OK;\n        }\n        cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));\n        if (cln == NULL) {\n            return NGX_ERROR;\n        }\n        rc = ngx_open_and_stat_file(name, of, pool->log);\n        if (rc == NGX_OK && !of->is_dir) {\n            cln->handler = ngx_pool_cleanup_file;\n            clnf = cln->data;\n            clnf->fd = of->fd;\n            clnf->name = name->data;\n            clnf->log = pool->log;\n        }\n        return rc;\n    }\n    cln = ngx_pool_cleanup_add(pool, sizeof(ngx_open_file_cache_cleanup_t));\n    if (cln == NULL) {\n        return NGX_ERROR;\n    }\n    now = ngx_time();\n    hash = ngx_crc32_long(name->data, name->len);\n    file = ngx_open_file_lookup(cache, name, hash);\n    if (file) {\n        file->uses++;\n        ngx_queue_remove(&file->queue);\n        if (file->fd == NGX_INVALID_FILE && file->err == 0 && !file->is_dir) {\n            rc = ngx_open_and_stat_file(name, of, pool->log);\n            if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n                goto failed;\n            }\n            goto add_event;\n        }\n        if (file->use_event\n            || (file->event == NULL\n                && (of->uniq == 0 || of->uniq == file->uniq)\n                && now - file->created < of->valid\n#if (NGX_HAVE_OPENAT)\n                && of->disable_symlinks == file->disable_symlinks\n                && of->disable_symlinks_from == file->disable_symlinks_from\n#endif\n            ))\n        {\n            if (file->err == 0) {\n                of->fd = file->fd;\n                of->uniq = file->uniq;\n                of->mtime = file->mtime;\n                of->size = file->size;\n                of->is_dir = file->is_dir;\n                of->is_file = file->is_file;\n                of->is_link = file->is_link;\n                of->is_exec = file->is_exec;\n                of->is_directio = file->is_directio;\n                if (!file->is_dir) {\n                    file->count++;\n                    ngx_open_file_add_event(cache, file, of, pool->log);\n                }\n            } else {\n                of->err = file->err;\n#if (NGX_HAVE_OPENAT)\n                of->failed = file->disable_symlinks ? ngx_openat_file_n\n                                                    : ngx_open_file_n;\n#else\n                of->failed = ngx_open_file_n;\n#endif\n            }\n            goto found;\n        }\n        ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0,\n                       "retest open file: %s, fd:%d, c:%d, e:%d",\n                       file->name, file->fd, file->count, file->err);\n        if (file->is_dir) {\n            of->test_dir = 1;\n        }\n        of->fd = file->fd;\n        of->uniq = file->uniq;\n        rc = ngx_open_and_stat_file(name, of, pool->log);\n        if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n            goto failed;\n        }\n        if (of->is_dir) {\n            if (file->is_dir || file->err) {\n                goto update;\n            }\n        } else if (of->err == 0) {\n            if (file->is_dir || file->err) {\n                goto add_event;\n            }\n            if (of->uniq == file->uniq) {\n                if (file->event) {\n                    file->use_event = 1;\n                }\n                of->is_directio = file->is_directio;\n                goto update;\n            }\n        } else {\n            if (file->err || file->is_dir) {\n                goto update;\n            }\n        }\n        if (file->count == 0) {\n            ngx_open_file_del_event(file);\n            if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {\n                ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                              ngx_close_file_n " \\"%V\\" failed", name);\n            }\n            goto add_event;\n        }\n        ngx_rbtree_delete(&cache->rbtree, &file->node);\n        cache->current--;\n        file->close = 1;\n        goto create;\n    }\n    rc = ngx_open_and_stat_file(name, of, pool->log);\n    if (rc != NGX_OK && (of->err == 0 || !of->errors)) {\n        goto failed;\n    }\ncreate:\n    if (cache->current >= cache->max) {\n        ngx_expire_old_cached_files(cache, 0, pool->log);\n    }\n    file = ngx_alloc(sizeof(ngx_cached_open_file_t), pool->log);\n    if (file == NULL) {\n        goto failed;\n    }\n    file->name = ngx_alloc(name->len + 1, pool->log);\n    if (file->name == NULL) {\n        ngx_free(file);\n        file = NULL;\n        goto failed;\n    }\n    ngx_cpystrn(file->name, name->data, name->len + 1);\n    file->node.key = hash;\n    ngx_rbtree_insert(&cache->rbtree, &file->node);\n    cache->current++;\n    file->uses = 1;\n    file->count = 0;\n    file->use_event = 0;\n    file->event = NULL;\nadd_event:\n    ngx_open_file_add_event(cache, file, of, pool->log);\nupdate:\n    file->fd = of->fd;\n    file->err = of->err;\n#if (NGX_HAVE_OPENAT)\n    file->disable_symlinks = of->disable_symlinks;\n    file->disable_symlinks_from = of->disable_symlinks_from;\n#endif\n    if (of->err == 0) {\n        file->uniq = of->uniq;\n        file->mtime = of->mtime;\n        file->size = of->size;\n        file->close = 0;\n        file->is_dir = of->is_dir;\n        file->is_file = of->is_file;\n        file->is_link = of->is_link;\n        file->is_exec = of->is_exec;\n        file->is_directio = of->is_directio;\n        if (!of->is_dir) {\n            file->count++;\n        }\n    }\n    file->created = now;\nfound:\n    file->accessed = now;\n    ngx_queue_insert_head(&cache->expire_queue, &file->queue);\n    ngx_log_debug5(NGX_LOG_DEBUG_CORE, pool->log, 0,\n                   "cached open file: %s, fd:%d, c:%d, e:%d, u:%d",\n                   file->name, file->fd, file->count, file->err, file->uses);\n    if (of->err == 0) {\n        if (!of->is_dir) {\n            cln->handler = ngx_open_file_cleanup;\n            ofcln = cln->data;\n            ofcln->cache = cache;\n            ofcln->file = file;\n            ofcln->min_uses = of->min_uses;\n            ofcln->log = pool->log;\n        }\n        return NGX_OK;\n    }\n    return NGX_ERROR;\nfailed:\n    if (file) {\n        ngx_rbtree_delete(&cache->rbtree, &file->node);\n        cache->current--;\n        if (file->count == 0) {\n            if (file->fd != NGX_INVALID_FILE) {\n                if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {\n                    ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                                  ngx_close_file_n " \\"%s\\" failed",\n                                  file->name);\n                }\n            }\n            ngx_free(file->name);\n            ngx_free(file);\n        } else {\n            file->close = 1;\n        }\n    }\n    if (of->fd != NGX_INVALID_FILE) {\n        if (ngx_close_file(of->fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,\n                          ngx_close_file_n " \\"%V\\" failed", name);\n        }\n    }\n    return NGX_ERROR;\n}', 'static ngx_int_t\nngx_file_info_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,\n    ngx_file_info_t *fi, ngx_log_t *log)\n{\n    ngx_int_t  rc;\n#if !(NGX_HAVE_OPENAT)\n    rc = ngx_file_info(name->data, fi);\n    if (rc == NGX_FILE_ERROR) {\n        of->err = ngx_errno;\n        of->failed = ngx_file_info_n;\n        return NGX_FILE_ERROR;\n    }\n    return rc;\n#else\n    ngx_fd_t  fd;\n    if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_OFF) {\n        rc = ngx_file_info(name->data, fi);\n        if (rc == NGX_FILE_ERROR) {\n            of->err = ngx_errno;\n            of->failed = ngx_file_info_n;\n            return NGX_FILE_ERROR;\n        }\n        return rc;\n    }\n    fd = ngx_open_file_wrapper(name, of, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,\n                               NGX_FILE_OPEN, 0, log);\n    if (fd == NGX_INVALID_FILE) {\n        return NGX_FILE_ERROR;\n    }\n    rc = ngx_fd_info(fd, fi);\n    if (rc == NGX_FILE_ERROR) {\n        of->err = ngx_errno;\n        of->failed = ngx_fd_info_n;\n    }\n    if (ngx_close_file(fd) == NGX_FILE_ERROR) {\n        ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,\n                      ngx_close_file_n " \\"%V\\" failed", name);\n    }\n    return rc;\n#endif\n}', 'static ngx_fd_t\nngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,\n    ngx_int_t mode, ngx_int_t create, ngx_int_t access, ngx_log_t *log)\n{\n    ngx_fd_t  fd;\n#if !(NGX_HAVE_OPENAT)\n    fd = ngx_open_file(name->data, mode, create, access);\n    if (fd == NGX_INVALID_FILE) {\n        of->err = ngx_errno;\n        of->failed = ngx_open_file_n;\n        return NGX_INVALID_FILE;\n    }\n    return fd;\n#else\n    u_char           *p, *cp, *end;\n    ngx_fd_t          at_fd;\n    ngx_str_t         at_name;\n    if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_OFF) {\n        fd = ngx_open_file(name->data, mode, create, access);\n        if (fd == NGX_INVALID_FILE) {\n            of->err = ngx_errno;\n            of->failed = ngx_open_file_n;\n            return NGX_INVALID_FILE;\n        }\n        return fd;\n    }\n    p = name->data;\n    end = p + name->len;\n    at_name = *name;\n    if (of->disable_symlinks_from) {\n        cp = p + of->disable_symlinks_from;\n        *cp = \'\\0\';\n        at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,\n                              NGX_FILE_OPEN, 0);\n        *cp = \'/\';\n        if (at_fd == NGX_INVALID_FILE) {\n            of->err = ngx_errno;\n            of->failed = ngx_open_file_n;\n            return NGX_INVALID_FILE;\n        }\n        at_name.len = of->disable_symlinks_from;\n        p = cp + 1;\n    } else if (*p == \'/\') {\n        at_fd = ngx_open_file("/",\n                              NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,\n                              NGX_FILE_OPEN, 0);\n        if (at_fd == NGX_INVALID_FILE) {\n            of->err = ngx_errno;\n            of->failed = ngx_openat_file_n;\n            return NGX_INVALID_FILE;\n        }\n        at_name.len = 1;\n        p++;\n    } else {\n        at_fd = NGX_AT_FDCWD;\n    }\n    for ( ;; ) {\n        cp = ngx_strlchr(p, end, \'/\');\n        if (cp == NULL) {\n            break;\n        }\n        if (cp == p) {\n            p++;\n            continue;\n        }\n        *cp = \'\\0\';\n        if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER) {\n            fd = ngx_openat_file_owner(at_fd, p,\n                                       NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,\n                                       NGX_FILE_OPEN, 0, log);\n        } else {\n            fd = ngx_openat_file(at_fd, p,\n                           NGX_FILE_SEARCH|NGX_FILE_NONBLOCK|NGX_FILE_NOFOLLOW,\n                           NGX_FILE_OPEN, 0);\n        }\n        *cp = \'/\';\n        if (fd == NGX_INVALID_FILE) {\n            of->err = ngx_errno;\n            of->failed = ngx_openat_file_n;\n            goto failed;\n        }\n        if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) {\n            ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,\n                          ngx_close_file_n " \\"%V\\" failed", &at_name);\n        }\n        p = cp + 1;\n        at_fd = fd;\n        at_name.len = cp - at_name.data;\n    }\n    if (p == end) {\n        fd = ngx_openat_file(at_fd, ".", mode, create, access);\n        goto done;\n    }\n    if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER\n        && !(create & (NGX_FILE_CREATE_OR_OPEN|NGX_FILE_TRUNCATE)))\n    {\n        fd = ngx_openat_file_owner(at_fd, p, mode, create, access, log);\n    } else {\n        fd = ngx_openat_file(at_fd, p, mode|NGX_FILE_NOFOLLOW, create, access);\n    }\ndone:\n    if (fd == NGX_INVALID_FILE) {\n        of->err = ngx_errno;\n        of->failed = ngx_openat_file_n;\n    }\nfailed:\n    if (at_fd != NGX_AT_FDCWD && ngx_close_file(at_fd) == NGX_FILE_ERROR) {\n        ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,\n                      ngx_close_file_n " \\"%V\\" failed", &at_name);\n    }\n    return fd;\n#endif\n}']