Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-06-21Core: added the ngx_rbtree_data() macro.Vladimir Homutov
2021-05-25Resolver: explicit check for compression pointers in question.Maxim Dounin
Since nginx always uses exactly one entry in the question section of a DNS query, and never uses compression pointers in this entry, parsing of a DNS response in ngx_resolver_process_response() does not expect compression pointers to appear in the question section of the DNS response. Indeed, compression pointers in the first name of a DNS response hardly make sense, do not seem to be allowed by RFC 1035 (which says "a pointer to a prior occurance of the same name", note "prior"), and were never observed in practice. Added an explicit check to ngx_resolver_process_response()'s parsing of the question section to properly report an error if compression pointers nevertheless appear in the question section.
2021-05-25Resolver: simplified ngx_resolver_copy().Maxim Dounin
Instead of checking on each label if we need to place a dot or not, now it always adds a dot after a label, and reduces the resulting length afterwards.
2021-05-25Resolver: reworked ngx_resolver_copy() copy loop.Maxim Dounin
To make the code easier to read, reworked the ngx_resolver_copy() copy loop to match the one used to calculate length. No functional changes.
2021-05-25Resolver: fixed label types handling in ngx_resolver_copy().Maxim Dounin
Previously, anything with any of the two high bits set were interpreted as compression pointers. This is incorrect, as RFC 1035 clearly states that "The 10 and 01 combinations are reserved for future use". Further, the 01 combination is actually allocated for EDNS extended label type (see RFC 2671 and RFC 6891), not really used though. Fix is to reject unrecognized label types rather than misinterpreting them as compression pointers.
2021-05-25Resolver: fixed off-by-one read in ngx_resolver_copy().Maxim Dounin
It is believed to be harmless, and in the worst case it uses some uninitialized memory as a part of the compression pointer length, eventually leading to the "name is out of DNS response" error.
2021-05-25Resolver: fixed off-by-one write in ngx_resolver_copy().Maxim Dounin
Reported by Luis Merino, Markus Vervier, Eric Sesterhenn, X41 D-Sec GmbH.
2021-04-08Introduced the "keepalive_time" directive.Maxim Dounin
Similar to lingering_time, it limits total connection lifetime before keepalive is switched off. The default is 1 hour, which is close to the total maximum connection lifetime possible with default keepalive_requests and keepalive_timeout.
2021-03-28Resolver: added missing event handling after reading.Maxim Dounin
If we need to be notified about further events, ngx_handle_read_event() needs to be called after a read event is processed. Without this, an event can be removed from the kernel and won't be reported again, notably when using oneshot event methods, such as eventport on Solaris. While here, error handling is also added, similar to one present in ngx_resolver_tcp_read(). This is not expected to make a difference and mostly added for consistency.
2020-09-28Resolver: improved error messages (ticket #2024).Maxim Dounin
2019-09-10Resolver: fixed possible use-after-free while resolving PTR.Sergey Kandaurov
Previously, if a response to the PTR request was cached, and ngx_resolver_dup() failed to allocate memory for the resulting name, then the original node was freed but left in expire_queue. A subsequent address resolving would end up in a use-after-free memory access of the node either in ngx_resolver_expire() or ngx_resolver_process_ptr(), when accessing it through expire_queue. The fix is to leave the resolver node intact.
2018-12-11Resolver: report SRV resolve failure if all A resolves failed.Roman Arutyunyan
Previously, if an SRV record was successfully resolved, but all of its A records failed to resolve, NXDOMAIN was returned to the caller, which is considered a successful resolve rather than an error. This could result in losing the result of a previous successful resolve by the caller. Now NXDOMAIN is only returned if at least one A resolve completed with this code. Otherwise the error state of the first A resolve is returned.
2018-07-05Resolver: retry sending queries on errors (ticket #1511).Maxim Dounin
Errors when sending UDP datagrams can happen, e.g., when local IP address changes (see fa0e093b64d7), or an unavailable DNS server on the LAN can cause send() to fail with EHOSTDOWN on BSD systems. If this happens during initial query, retry sending immediately, to a different DNS server when possible. If this is not enough, allow normal resend to happen by ignoring the return code of the second ngx_resolver_send_query() call, much like we do in ngx_resolver_resend().
2018-06-13Resolver: require name servers.Ruslan Ermilov
2018-06-13Resolver: allocate resolver from configuration pool.Ruslan Ermilov
Before 4a8c9139e579, ngx_resolver_create() didn't use configuration pool, and allocations were done using malloc(). In 016352c19049, when resolver gained support of several servers, new allocations were done from the pool.
2018-06-05Added missing space after ngx_close_socket_n.Maxim Dounin
2018-05-23Resolver: close UDP socket on error or incomplete send.Ruslan Ermilov
2018-05-23Resolver: style.Ruslan Ermilov
2017-07-04Resolver: cancelable resend timer event.Ruslan Ermilov
It is safe because re-sending still works during graceful shutdown as long as resolving takes place (and resolve tasks set their own timeouts that are not cancelable). Also, the new ctx->cancelable flag can be set to make resolve task's timeout event cancelable.
2017-07-04Resolver: factored out setting a timer for resolver timeout.Sergey Kandaurov
No functional changes.
2017-07-04Resolver: fixed possible use-after-free while resolving SRV.Roman Arutyunyan
Resolving an SRV record includes resolving its host names in subrequests. Previously, if memory allocation failed while reporting a subrequest result after receiving a response from a DNS server, the SRV resolve handler was called immediately with the NGX_ERROR state. However, if the SRV record included another copy of the resolved name, it was reported once again. This could trigger the use-after-free memory access after SRV resolve handler freed the resolve context by calling ngx_resolve_name_done(). Now the SRV resolve handler is called only when all its subrequests are completed.
2017-06-14Resolver: added the "async" flag to resolver context.Roman Arutyunyan
The flag indicates that the resolve handler is called asynchronously after the resolve function ngx_resolve_name()/ngx_resolve_addr() exited.
2017-06-19Resolver: fixed allocation error handling while resolving SRV.Bart Warmerdam
2017-03-02Added missing static specifiers.Eran Kornblau
2016-12-24Win32: fixed some warnings reported by Borland C.Maxim Dounin
Most notably, warning W8012 (comparing signed and unsigned values) reported in multiple places where an unsigned value of small type (e.g., u_short) is promoted to an int and compared to an unsigned value. Warning W8072 (suspicious pointer arithmetic) disabled, it is reported when we increment base pointer in ngx_shm_alloc().
2016-12-16Resolver: fixed handling of partially resolved SRV.Dmitry Volyntsev
The resolver handles SRV requests in two stages. In the first stage it gets all SRV RRs, and in the second stage it resolves the names from SRV RRs into addresses. Previously, if a response to an SRV request was cached, the queries to resolve names were not limited by a timeout. If a response to any of these queries was not received, the SRV request could never complete. If a response to an SRV request was not cached, and some of the queries to resolve names timed out, NGX_RESOLVE_TIMEDOUT was returned instead of successfully resolved addresses. To fix both issues, resolving of names is now always limited by a timeout.
2016-12-16Resolver: fixed a race between parallel name and addr resolves.Dmitry Volyntsev
Previously, ngx_resolve_name() and ngx_resolve_addr() may have rescheduled the resend timer while it was already in progress.
2016-12-16Resolver: fixed possible premature stop of the resend timer.Dmitry Volyntsev
Previously, ngx_resolve_name_done() and ngx_resolve_addr_done() may have stopped the resend timer prematurely while srv_resend_queue was not empty.
2016-12-16Resolver: fixed possible use-after-free in worker on fast shutdown.Ruslan Ermilov
The fix in a3dc657f4e95 was incomplete.
2016-12-15Resolver: fixed possible use-after-free in worker on fast shutdown.Ruslan Ermilov
2016-09-29Resolver: introduced state field in ngx_resolver_srv_name_t.Dmitry Volyntsev
It keeps the actual state value of a DNS SRV subrequest and can be used to report a more detailed log for failed SRV records.
2016-06-20Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan
2016-05-23Introduced the ngx_sockaddr_t type.Ruslan Ermilov
It's properly aligned and can hold any supported sockaddr.
2016-04-08Removed redundant "u" format specifier.Ruslan Ermilov
It is implied for "x" and "X".
2016-03-31Fixed logging with variable field width.Sergey Kandaurov
2016-03-23Win32: fixed build after 384154fc634f.Dmitry Volyntsev
2016-03-23Resolver: added support for SRV records.Dmitry Volyntsev
2016-03-23Resolver: do not enable resolve timer if provided timeout is zero.Dmitry Volyntsev
2016-03-23Resolver: introduced valid field in resolver responses.Dmitry Volyntsev
It hints the amount of time a response could be considered as valid.
2015-12-17Resolver: style.Ruslan Ermilov
Use the original query name in error and debug messages when processing PTR responses.
2015-12-17Resolver: improved PTR response processing.Ruslan Ermilov
The previous code only parsed the first answer, without checking its type, and required a compressed RR name. The new code checks the RR type, supports responses with multiple answers, and doesn't require the RR name to be compressed. This has a side effect in limited support of CNAME. If a response includes both CNAME and PTR RRs, like when recursion is enabled on the server, PTR RR is handled. Full CNAME support in PTR response is not implemented in this change.
2015-12-17Resolver: style.Ruslan Ermilov
Renamed argument in ngx_resolver_process_a() for consistency.
2016-02-02Resolver: free TCP buffers on resolver cleanup.Roman Arutyunyan
2016-02-02Resolver: fixed possible resource leak introduced in 5a16d40c63de.Ruslan Ermilov
Found by Coverity (CID 1351175).
2016-01-28Resolver: TCP support.Roman Arutyunyan
Resend DNS query over TCP once UDP response came truncated.
2016-01-28Resolver: per-request DNS server balancer.Roman Arutyunyan
Previously, a global server balancer was used to assign the next DNS server to send a query to. That could lead to a non-uniform distribution of servers per request. A request could be assigned to the same dead server several times in a row and wait longer for a valid server or even time out without being processed. Now each query is sent to all servers sequentially in a circle until a response is received or timeout expires. Initial server for each request is still globally balanced.
2016-01-28Resolver: renamed UDP-specific structures, fields and variables.Roman Arutyunyan
They will be used for TCP connections as well.
2016-01-26Resolver: limited CNAME recursion.Ruslan Ermilov
Previously, the recursion was only limited for cached responses.
2016-01-26Resolver: fixed use-after-free memory accesses with CNAME.Roman Arutyunyan
When several requests were waiting for a response, then after getting a CNAME response only the last request's context had the name updated. Contexts of other requests had the wrong name. This name was used by ngx_resolve_name_done() to find the node to remove the request context from. When the name was wrong, the request could not be properly cancelled, its context was freed but stayed linked to the node's waiting list. This happened e.g. when the first request was aborted or timed out before the resolving completed. When it completed, this triggered a use-after-free memory access by calling ctx->handler of already freed request context. The bug manifests itself by "could not cancel <name> resolving" alerts in error_log. When a request was responded with a CNAME, the request context kept the pointer to the original node's rn->u.cname. If the original node expired before the resolving timed out or completed with an error, this would trigger a use-after-free memory access via ctx->name in ctx->handler(). The fix is to keep ctx->name unmodified. The name from context is no longer used by ngx_resolve_name_done(). Instead, we now keep the pointer to resolver node to which this request is linked. Keeping the original name intact also improves logging.
2016-01-26Resolver: changed the ngx_resolver_create_*_query() arguments.Roman Arutyunyan
No functional changes. This is needed by the following change.