summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-12-24Win32: minimized redefinition of intptr_t/uintptr_t.Maxim Dounin1-1/+1
These types are available with MSVC (at least since 2003, in stddef.h), all variants of GCC (in stdint.h) and Watcom C. We need to define them only for Borland C.
2016-12-24Win32: stdint.h used for MinGW GCC.Maxim Dounin1-1/+1
There is no need to restrict stdint.h only to MinGW-w64 GCC, it is available with MinGW GCC as well.
2016-12-24Win32: fixed building with newer versions of MinGW GCC.Maxim Dounin1-0/+1
Macro to indicate that off_t was defined has been changed, so we now additionally define the new one.
2016-12-23SSL: support AES256 encryption of tickets.Maxim Dounin2-16/+47
This implies ticket key size of 80 bytes instead of previously used 48, as both HMAC and AES keys are 32 bytes now. When an old 48-byte ticket key is provided, we fall back to using backward-compatible AES128 encryption. OpenSSL switched to using AES256 in 1.1.0, and we are providing equivalent security. While here, order of HMAC and AES keys was reverted to make the implementation compatible with keys used by OpenSSL with SSL_CTX_set_tlsext_ticket_keys(). Prodded by Christian Klinger.
2016-12-22Fixed missing "Location" field with some relative redirects.Ruslan Ermilov4-18/+10
Relative redirects did not work with directory redirects and auto redirects issued by nginx.
2016-12-21Core: relative redirects (closes #1000).Ruslan Ermilov4-2/+16
The current version of HTTP/1.1 standard allows relative references in redirects (https://tools.ietf.org/html/rfc7231#section-7.1.2). Allow this form for redirects generated by nginx by introducing the new directive absolute_redirect.
2016-12-21Limited recursion when evaluating variables.Ruslan Ermilov2-13/+61
Unlimited recursion might cause stack exhaustion in some misconfigurations.
2016-12-20Stream: client SSL certificates verification support.Vladimir Homutov2-0/+157
New directives: "ssl_verify_client", "ssl_verify_depth", "ssl_client_certificate", "ssl_trusted_certificate", and "ssl_crl". New variables: $ssl_client_cert, $ssl_client_raw_cert, $ssl_client_s_dn, $ssl_client_i_dn, $ssl_client_serial, $ssl_client_fingerprint, $ssl_client_verify, $ssl_client_v_start, $ssl_client_v_end, and $ssl_client_v_remain.
2016-12-19Stream ssl_preread: relaxed SSL version check.Roman Arutyunyan1-1/+1
SSL version 3.0 can be specified by the client at the record level for compatibility reasons. Previously, ssl_preread module rejected such connections, presuming they don't have SNI. Now SSL 3.0 is allowed at the record level.
2016-12-16Resolver: fixed handling of partially resolved SRV.Dmitry Volyntsev1-1/+5
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 Volyntsev1-2/+2
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 Volyntsev1-0/+1
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 Ermilov1-0/+4
The fix in a3dc657f4e95 was incomplete.
2016-12-15Resolver: fixed possible use-after-free in worker on fast shutdown.Ruslan Ermilov1-0/+4
2016-12-15SSL: backed out changeset e7cb5deb951d, reimplemented properly.Maxim Dounin2-6/+6
Changeset e7cb5deb951d breaks build on CentOS 5 with "dereferencing type-punned pointer will break strict-aliasing rules" warning. It is backed out. Instead, to keep builds with BoringSSL happy, type of the "value" variable changed to "char *", and an explicit cast added before calling ngx_parse_http_time().
2016-12-13SSL: fix call to BIO_get_mem_data().Piotr Sikora2-2/+2
Fixes build with BoringSSL. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-12-15Access log: support for json escaping.Valentin Bartenev2-12/+154
2016-12-13The size of cmcf->phase_engine.handlers explained.Ruslan Ermilov1-1/+4
2016-12-13Version bump.Ruslan Ermilov1-2/+2
2016-12-10HTTP/2: prevented creating temp files for requests without body.Valentin Bartenev1-2/+4
The problem was introduced by 52bd8cc17f34.
2016-11-28HTTP/2: fixed posted streams handling.Valentin Bartenev3-38/+42
A bug was introduced by 82efcedb310b that could lead to timing out of responses or segmentation fault, when accept_mutex was enabled. The output queue in HTTP/2 can contain frames from different streams. When the queue is sent, all related write handlers need to be called. In order to do so, the streams were added to the h2c->posted queue after handling sent frames. Then this queue was processed in ngx_http_v2_write_handler(). If accept_mutex is enabled, the event's "ready" flag is set but its handler is not called immediately. Instead, the event is added to the ngx_posted_events queue. At the same time in this queue can be events from upstream connections. Such events can result in sending output queue before ngx_http_v2_write_handler() is triggered. And at the time ngx_http_v2_write_handler() is called, the output queue can be already empty with some streams added to h2c->posted. But after 82efcedb310b, these streams weren't processed if all frames have already been sent and the output queue was empty. This might lead to a situation when a number of streams were get stuck in h2c->posted queue for a long time. Eventually these streams might get closed by the send timeout. In the worst case this might also lead to a segmentation fault, if already freed stream was left in the h2c->posted queue. This could happen if one of the streams was terminated but wasn't closed, due to the HEADERS frame or a partially sent DATA frame left in the output queue. If this happened the ngx_http_v2_filter_cleanup() handler removed the stream from the h2c->waiting or h2c->posted queue on termination stage, before the frame has been sent, and the stream was again added to the h2c->posted queue after the frame was sent. In order to fix all these problems and simplify the code, write events of fake stream connections are now added to ngx_posted_events instead of using a custom h2c->posted queue.
2016-12-08Map: the "volatile" parameter.Ruslan Ermilov2-2/+28
By default, "map" creates cacheable variables [1]. With this parameter it creates a non-cacheable variable. An original idea was to deduce the cacheability of the "map" variable by checking the cacheability of variables specified in source and resulting values, but it turned to be too hard. For example, a cacheable variable can be overridden with the "set" directive or with the SSI "set" command. Also, keeping "map" variables cacheable by default is good for performance reasons. This required adding a new parameter. [1] Before db699978a33f (1.11.0), the cacheability of the "map" variable could vary depending on the cacheability of variables specified in resulting values (ticket #1090). This is believed to be a bug rather than a feature.
2016-12-08Map: simplified "map" block parser.Ruslan Ermilov2-2/+4
No functional changes.
2016-12-08Slab: commented bitmap initialization for small allocations.Ruslan Ermilov1-0/+1
2016-12-07Slab: free pages statistics.Ruslan Ermilov2-0/+6
2016-12-07Slab: slots statistics.Ruslan Ermilov2-11/+57
For each slot, the number of total and used entries, as well as the number of allocation requests and failures, are tracked.
2016-12-07Slab: simplified some math.Ruslan Ermilov1-17/+12
No functional changes.
2016-12-07Slab: simplified allocation from slots.Ruslan Ermilov1-79/+61
Removed code that would cause an endless loop, and removed condition check that is always false. The first page in the slot list is guaranteed to satisfy an allocation.
2016-12-07Slab: fixed the number of pages calculation.Ruslan Ermilov1-0/+1
When estimating the number of pages, do not count memory for slots. In some cases this gives one extra usable memory page.
2016-12-07Slab: added comment about list heads.Ruslan Ermilov1-1/+4
2016-12-07Slab: improved code readability.Ruslan Ermilov1-54/+49
No functional changes.
2016-12-07Core: fixed environment on exit.Maxim Dounin1-8/+40
On exit environment allocated from a pool is no longer available, leading to a segmentation fault if, for example, a library tries to use it from an atexit() handler. Fix is to allocate environment via ngx_alloc() instead, and explicitly free it using a pool cleanup handler if it's no longer used (e.g., on configuration reload).
2016-12-07Perl: removed special environment handling for the perl module.Maxim Dounin1-12/+1
In Perl 5.8.6 the default was switched to use putenv() when used as embedded library unless "PL_use_safe_putenv = 0" is explicitly used in the code. Therefore, for modern versions of Perl it is no longer necessary to restore previous environment when calling perl_destruct().
2016-12-07Perl: added PERL_SET_INTERP().Maxim Dounin1-0/+8
For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp remains set to the first interpreter created (that is, one created at original start). As a result after a reload Perl thinks that operations are done withing a thread, and, most notably, denies to change environment. For example, the following code properly works on original start, but fails after a reload: perl 'sub { my $r = shift; $r->send_http_header("text/plain"); $ENV{TZ} = "UTC"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); $ENV{TZ} = "Europe/Moscow"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); return OK; }'; To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT() was previously used. Note that PERL_SET_INTERP() doesn't seem to be documented anywhere. Yet it is used in some other software, and also seems to be the only solution possible.
2016-12-07Fixed spelling of logical AND operator, no functional changes.Sergey Kandaurov1-1/+1
Found by PVS-Studio.
2016-11-22Mp4: fixed setting wrong mdat atom size in very rare cases.hucongcong1-1/+3
Atom size is the sum of atom header size and atom data size. The specification says that the first 4 bytes are set to one when the atom size is greater than the maximum unsigned 32-bit value. Which means atom header size should be considered when the comparison takes place between atom data size and 0xffffffff.
2016-12-05SSL: $ssl_curves (ticket #1088).Maxim Dounin4-0/+76
The variable contains a list of curves as supported by the client. Known curves are listed by their names, unknown ones are shown in hex, e.g., "0x001d:prime256v1:secp521r1:secp384r1". Note that OpenSSL uses session data for SSL_get1_curves(), and it doesn't store full list of curves supported by the client when serializing a session. As a result $ssl_curves is only available for new sessions (and will be empty for reused ones). The variable is only meaningful when using OpenSSL 1.0.2 and above. With older versions the variable is empty.
2016-12-05SSL: $ssl_ciphers (ticket #870).Maxim Dounin4-0/+92
The variable contains list of ciphers as supported by the client. Known ciphers are listed by their names, unknown ones are shown in hex, e.g., ""AES128-SHA:AES256-SHA:0x00ff". The variable is fully supported only when using OpenSSL 1.0.2 and above. With older version there is an attempt to provide some information using SSL_get_shared_ciphers(). It only lists known ciphers though. Moreover, as OpenSSL uses session data for SSL_get_shared_ciphers(), and it doesn't store relevant data when serializing a session. As a result $ssl_ciphers is only available for new sessions (and not available for reused ones) when using OpenSSL older than 1.0.2.
2016-12-05SSL: $ssl_client_v_start, $ssl_client_v_end, $ssl_client_v_remain.Maxim Dounin3-0/+193
2016-12-05SSL: $ssl_client_verify extended with a failure reason.Maxim Dounin1-8/+18
Now in case of a verification failure $ssl_client_verify contains "FAILED:<reason>", similar to Apache's SSL_CLIENT_VERIFY, e.g., "FAILED:certificate has expired". Detailed description of possible errors can be found in the verify(1) manual page as provided by OpenSSL.
2016-12-05OCSP stapling: improved error logging context.Maxim Dounin1-1/+19
It now logs the IP address of the responder used (if it's already known), as well as the certificate name.
2016-12-05OCSP stapling: added certificate name to warnings.Maxim Dounin3-5/+36
2016-12-05OCSP stapling: added http response status logging.Maxim Dounin1-6/+9
2016-12-05OCSP stapling: style.Maxim Dounin1-10/+12
2016-12-03Slab: improved double free detection.Ruslan Ermilov1-1/+1
Previously, an attempt to double free the starting page of the free range was not detected.
2016-12-03Slab: always show the requested allocation size in debug messages.Ruslan Ermilov1-1/+0
Previously, allocations smaller than min_size were shown as min_size.
2016-12-03Slab: style.Ruslan Ermilov1-3/+3
Removed redundant parentheses. No functional changes.
2016-11-21Events: improved error event handling for UDP sockets.Dmitry Volyntsev4-30/+19
Normally, the epoll module calls the read and write handlers depending on whether EPOLLIN and EPOLLOUT are reported by epoll_wait(). No error processing is done in the module, the handlers are expected to get an error when doing I/O. If an error event is reported without EPOLLIN and EPOLLOUT, the module set both EPOLLIN and EPOLLOUT to ensure the error event is handled at least in one active handler. This works well unless the error is delivered along with only one of EPOLLIN or EPOLLOUT, and the corresponding handler does not do any I/O. For example, it happened when getting EPOLLERR|EPOLLOUT from epoll_wait() upon receiving "ICMP port unreachable" while proxying UDP. As the write handler had nothing to send it was not able to detect and log an error, and did not switch to the next upstream. The fix is to unconditionally set EPOLLIN and EPOLLOUT in case of an error event. In the aforementioned case, this causes the read handler to be called which does recv() and detects an error. In addition to the epoll module, analogous changes were made in devpoll/eventport/poll.
2016-11-28HTTP/2: fixed saving preread buffer to temp file (ticket #1143).Valentin Bartenev1-0/+3
Previously, a request body bigger than "client_body_buffer_size" wasn't written into a temporary file if it has been pre-read entirely. The preread buffer is freed after processing, thus subsequent use of it might result in sending corrupted body or cause a segfault.
2016-11-21Version bump.Maxim Dounin1-2/+2