summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-12-21Allowed configuration token to start with a variable.Roman Arutyunyan1-0/+5
Specifically, it is now allowed to start with a variable expression with braces: ${name}. The opening curly bracket in such a token was previously considered the start of a new block. Variables located anywhere else in a token worked fine: foo${name}.
2017-12-13Retain CAP_NET_RAW capability for transparent proxying.Roman Arutyunyan1-0/+2
The capability is retained automatically in unprivileged worker processes after changing UID if transparent proxying is enabled at least once in nginx configuration. The feature is only available in Linux.
2017-11-28Fixed "changing binary" when reaper is not init.Ruslan Ermilov1-0/+1
On some systems, it's possible that reaper of orphaned processes is set to something other than "init" process. On such systems, the changing binary procedure did not work. The fix is to check if PPID has changed, instead of assuming it's always 1 for orphaned processes.
2017-11-23Version bump.Maxim Dounin1-2/+2
2017-10-17Core: free shared memory zones only after reconfiguration.Maxim Dounin1-7/+17
This is what usually happens for zones no longer used in the new configuration, but zones where size or tag were changed were freed when creating new memory zones. If reconfiguration failed (for example, due to a conflicting listening socket), this resulted in a segmentation fault in the master process. Reported by Zhihua Cao, http://mailman.nginx.org/pipermail/nginx-devel/2017-October/010536.html.
2017-10-13Fixed type of ngx_conf_t.handler_conf.Ruslan Ermilov1-1/+1
The type should have been changed in c9b243802a17 along with changing ngx_conf_handler_pt.
2017-10-11Version bump.Ruslan Ermilov1-2/+2
2017-10-05Fixed build without IPv6, broken by 874171c3c71a.Maxim Dounin1-1/+3
2017-10-04Fixed handling of non-null-terminated unix sockets.Maxim Dounin3-1/+21
At least FreeBSD, macOS, NetBSD, and OpenBSD can return unix sockets with non-null-terminated sun_path. Additionally, the address may become non-null-terminated if it does not fit into the buffer provided and was truncated (may happen on macOS, NetBSD, and Solaris, which allow unix socket addresess larger than struct sockaddr_un). As such, ngx_sock_ntop() might overread the sockaddr provided, as it used "%s" format and thus assumed null-terminated string. To fix this, the ngx_strnlen() function was introduced, and it is now used to calculate correct length of sun_path.
2017-10-04Fixed buffer overread with unix sockets after accept().Maxim Dounin1-0/+4
Some OSes (notably macOS, NetBSD, and Solaris) allow unix socket addresses larger than struct sockaddr_un. Moreover, some of them (macOS, Solaris) return socklen of the socket address before it was truncated to fit the buffer provided. As such, on these systems socklen must not be used without additional check that it is within the buffer provided. Appropriate checks added to ngx_event_accept() (after accept()), ngx_event_recvmsg() (after recvmsg()), and ngx_set_inherited_sockets() (after getsockname()). We also obtain socket addresses via getsockname() in ngx_connection_local_sockaddr(), but it does not need any checks as it is only used for INET and INET6 sockets (as there can be no wildcard unix sockets).
2017-09-25Fixed the NGX_UNIX_ADDRSTRLEN macro.Ruslan Ermilov1-2/+3
2017-09-13Introduced time truncation to December 31, 9999 (ticket #1368).Maxim Dounin1-0/+10
Various buffers are allocated in an assumption that there would be no more than 4 year digits. This might not be true on platforms with 64-bit time_t, as 64-bit time_t is able to represent more than that. Such dates with more than 4 year digits hardly make sense though, as various date formats in use do not allow them anyway. As such, all dates are now truncated by ngx_gmtime() to December 31, 9999. This should have no effect on valid dates, though will prevent potential buffer overflows on invalid ones.
2017-09-13Fixed ngx_gmtime() on 32-bit platforms with 64-bit time_t.Maxim Dounin1-8/+10
In ngx_gmtime(), instead of casting to ngx_uint_t we now work with time_t directly. This allows using dates after 2038 on 32-bit platforms which use 64-bit time_t, notably NetBSD and OpenBSD. As the code is not able to work with negative time_t values, argument is now set to 0 for negative values. As a positive side effect, this results in Epoch being used for such values instead of a date in distant future.
2017-09-13Fixed reference to time parsing code after 8b6fa4842133.Maxim Dounin1-1/+1
2017-09-13Style.Maxim Dounin1-2/+3
2017-09-11Version bump.Roman Arutyunyan1-2/+2
2017-08-10Style.Maxim Dounin1-2/+2
2017-08-09Style.Sergey Kandaurov1-0/+1
2017-08-09Version bump.Sergey Kandaurov1-2/+2
2017-08-08Slab: fixed initialization on win32.Ruslan Ermilov3-10/+20
On Windows, a worker process does not call ngx_slab_init() from ngx_init_zone_pool(), so ngx_slab_max_size, ngx_slab_exact_size, and ngx_slab_exact_shift were left uninitialized.
2017-07-17Parenthesized ASCII-related calculations.Valentin Bartenev2-12/+12
This also fixes potential undefined behaviour in the range and slice filter modules, caused by local overflows of signed integers in expressions.
2017-07-11Core: fixed error message on setsockopt(SO_REUSEPORT) failure.Maxim Dounin1-1/+1
The error is fatal when configuring a new socket, so the ", ignored" part is not appropriate and was removed.
2017-07-11Core: disabled SO_REUSEPORT when testing config (ticket #1300).Maxim Dounin1-1/+1
When closing a socket with SO_REUSEPORT, Linux drops all connections waiting in this socket's listen queue. Previously, it was believed to only result in connection resets when reconfiguring nginx to use smaller number of worker processes. It also results in connection resets during configuration testing though. Workaround is to avoid using SO_REUSEPORT when testing configuration. It should prevent listening sockets from being created if a conflicting socket already exists, while still preserving detection of other possible errors. It should also cover UDP sockets. The only downside of this approach seems to be that a configuration testing won't be able to properly report the case when nginx was compiled with SO_REUSEPORT, but the kernel is not able to set it. Such errors will be reported on a real start instead.
2017-07-11Version bump.Maxim Dounin1-2/+2
2017-07-04Resolver: cancelable resend timer event.Ruslan Ermilov2-0/+3
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 Kandaurov1-50/+33
No functional changes.
2017-07-04Slab: fixed small allocations on systems with large pagesize.Ruslan Ermilov1-4/+13
Notably, on ppc64 with 64k pagesize, slab 0 (of size 8) requires 128 64-bit elements for bitmasks. The code bogusly assumed that one uintptr_t is enough for bitmasks plus at least one free slot.
2017-07-04Slab: style.Ruslan Ermilov1-10/+10
2017-07-04Resolver: fixed possible use-after-free while resolving SRV.Roman Arutyunyan1-19/+19
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-07-03Version bump.Maxim Dounin1-2/+2
2017-06-14Resolver: added the "async" flag to resolver context.Roman Arutyunyan2-1/+7
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 Warmerdam1-1/+3
2017-06-16Introduced ngx_rwlock_downgrade().Ruslan Ermilov2-0/+10
2017-06-16Added memory barrier semantics to ngx_rwlock_unlock().Ruslan Ermilov1-1/+1
2017-06-14Removed excessive casts for ngx_file_info().Ruslan Ermilov2-6/+2
2017-05-30Version bump.Valentin Bartenev1-2/+2
2017-05-26Introduced ngx_tcp_nodelay().Ruslan Ermilov2-0/+44
2017-04-27Added missing "fall through" comments (ticket #1259).Maxim Dounin1-0/+2
Found by gcc7 (-Wimplicit-fallthrough).
2017-04-25Version bump.Ruslan Ermilov1-2/+2
2017-04-18Core: removed extra ngx_alloc() and ngx_calloc() prototypes.Sergey Kandaurov1-3/+0
2017-04-12Core: improved JSON escaping.Valentin Bartenev1-5/+42
Two-character representations are now used for \b, \f, \n, \r, and \t.
2017-04-12Version bump.Ruslan Ermilov1-2/+2
2017-03-28Use ngx_array_init() to initialize arrays.Ruslan Ermilov1-19/+15
2017-03-28Version bump.Ruslan Ermilov1-2/+2
2017-03-22Version bump.Ruslan Ermilov1-2/+2
2017-03-07Introduced worker_shutdown_timeout.Maxim Dounin3-0/+64
The directive configures a timeout to be used when gracefully shutting down worker processes. When the timer expires, nginx will try to close all the connections currently open to facilitate shutdown.
2017-03-07Core: introduced ngx_rbtree_next().Maxim Dounin2-0/+31
2017-03-07Removed casts not needed after 1f513d7f1b45.Ruslan Ermilov1-2/+2
2017-03-02Added missing static specifiers.Eran Kornblau1-4/+4
2017-02-17Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings.Maxim Dounin1-0/+10