diff options
author | Ruslan Ermilov <ru@nginx.com> | 2016-01-26 16:47:14 +0300 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2016-01-26 16:47:14 +0300 |
commit | fe89d99796d42b86816e17d9c87ab16964768024 (patch) | |
tree | 16f8ccf1ad7663b28e46b8d5cb150b5d2c0b30ef | |
parent | a3d42258d97ebd0b638c20976654d3edfbaf943f (diff) |
Resolver: limited CNAME recursion.
Previously, the recursion was only limited for cached responses.
-rw-r--r-- | src/core/ngx_resolver.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index d1beb5812..7b60abd49 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -2001,11 +2001,33 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, ngx_queue_insert_head(&r->name_expire_queue, &rn->queue); + ngx_resolver_free(r, rn->query); + rn->query = NULL; +#if (NGX_HAVE_INET6) + rn->query6 = NULL; +#endif + ctx = rn->waiting; rn->waiting = NULL; if (ctx) { + if (ctx->recursion++ >= NGX_RESOLVER_MAX_RECURSION) { + + /* unlock name mutex */ + + do { + ctx->state = NGX_RESOLVE_NXDOMAIN; + next = ctx->next; + + ctx->handler(ctx); + + ctx = next; + } while (ctx); + + return; + } + for (next = ctx; next; next = next->next) { next->node = NULL; } @@ -2013,12 +2035,6 @@ ngx_resolver_process_a(ngx_resolver_t *r, u_char *buf, size_t last, (void) ngx_resolve_name_locked(r, ctx, &name); } - ngx_resolver_free(r, rn->query); - rn->query = NULL; -#if (NGX_HAVE_INET6) - rn->query6 = NULL; -#endif - /* unlock name mutex */ return; |