summaryrefslogtreecommitdiffhomepage
path: root/src/core (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-11-26Negative size buffers detection.Maxim Dounin1-4/+60
In the past, there were several security issues which resulted in worker process memory disclosure due to buffers with negative size. It looks reasonable to check for such buffers in various places, much like we already check for zero size buffers. While here, removed "#if 1 / #endif" around zero size buffer checks. It looks highly unlikely that we'll disable these checks anytime soon.
2018-11-15Core: ngx_explicit_memzero().Maxim Dounin2-0/+10
2018-11-15Core: free shared memory on cycle initialization failure.Ruslan Ermilov1-0/+64
2018-11-13Version bump.Vladimir Homutov1-2/+2
2018-10-03Version bump.Vladimir Homutov1-2/+2
2018-10-02Fixed off-by-one error in shared zone initialization.Ruslan Ermilov1-1/+2
On systems without atomic ops, not enough space was allocated for mutex's file name during shared zone initialization.
2018-09-27Version bump.Ruslan Ermilov1-2/+2
2018-08-30Version bump.Roman Arutyunyan1-2/+2
2018-08-09Skipping spaces in configuration files (ticket #1557).Maxim Dounin1-3/+4
Previously, a chunk of spaces larger than NGX_CONF_BUFFER (4096 bytes) resulted in the "too long parameter" error during parsing such a configuration. This was because the code only set start and start_line on non-whitespace characters, and hence adjacent whitespace characters were preserved when reading additional data from the configuration file. Fix is to always move start and start_line if the last character was a space.
2018-08-01Dav: changed ngx_copy_file() to preserve access and mtime.Maxim Dounin1-9/+13
This fixes wrong permissions and file time after cross-device MOVE in the DAV module (ticket #1577). Broken in 8101d9101ed8 (0.8.9) when cross-device copying was introduced in ngx_ext_rename_file(). With this change, ngx_copy_file() always calls ngx_set_file_time(), either with the time provided, or with the time from the original file. This is considered acceptable given that copying the file is costly anyway, and optimizing cases when we do not need to preserve time will require interface changes.
2018-08-01Dav: fixed ngx_copy_file() to truncate destination file.Maxim Dounin1-2/+1
Previously, ngx_open_file(NGX_FILE_CREATE_OR_OPEN) was used, resulting in destination file being partially rewritten if exists. Notably, this affected WebDAV COPY command (ticket #1576).
2018-07-24Version bump.Sergey Kandaurov1-2/+2
2018-07-12Events: moved sockets cloning to ngx_event_init_conf().Maxim Dounin2-6/+5
Previously, listenings sockets were not cloned if the worker_processes directive was specified after "listen ... reuseport". This also simplifies upcoming configuration check on the number of worker connections, as it needs to know the number of listening sockets before cloning.
2018-07-05Resolver: retry sending queries on errors (ticket #1511).Maxim Dounin1-2/+18
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-07-05Version bump.Maxim Dounin1-2/+2
2018-07-02Added FreeBSD support for "listen ... reuseport".Ruslan Ermilov1-0/+54
2018-06-13Resolver: require name servers.Ruslan Ermilov1-0/+5
2018-06-13Resolver: allocate resolver from configuration pool.Ruslan Ermilov1-43/+32
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 Dounin1-2/+2
2018-06-05Version bump.Maxim Dounin1-2/+2
2018-06-04Stream: udp streams.Roman Arutyunyan3-0/+10
Previously, only one client packet could be processed in a udp stream session even though multiple response packets were supported. Now multiple packets coming from the same client address and port are delivered to the same stream session. If it's required to maintain a single stream of data, nginx should be configured in a way that all packets from a client are delivered to the same worker. On Linux and DragonFly BSD the "reuseport" parameter should be specified for this. Other systems do not currently provide appropriate mechanisms. For these systems a single stream of udp packets is only guaranteed in single-worker configurations. The proxy_response directive now specifies how many packets are expected in response to a single client packet.
2018-06-04Leave chain in ngx_chain_add_copy() in consistent state on errors.Sergey Kandaurov1-0/+1
2018-05-29Core: fixed comment about ngx_current_msec after 81fae70d6cb8.Ruslan Ermilov1-2/+2
The value is no longer guaranteed to be based on milliseconds elapsed since Epoch.
2018-05-14Syslog: install cleanup handler only once.Vladimir Homutov2-17/+16
If a socket was re-opened due to an error (02c2352d5b01 and fa0e093b64d7), additional cleanup handler was installed each time.
2018-05-23Resolver: close UDP socket on error or incomplete send.Ruslan Ermilov1-2/+9
2018-05-23Resolver: style.Ruslan Ermilov1-2/+2
2018-05-21Core: silenced getsockopt(TCP_FASTOPEN) messages on FreeBSD.Maxim Dounin1-1/+3
FreeBSD returns EINVAL when getsockopt(TCP_FASTOPEN) is called on a unix domain socket, resulting in "getsockopt(TCP_FASTOPEN) ... failed" messages during binary upgrade when unix domain listen sockets are present in the configuration. Added EINVAL to the list of ignored error codes.
2018-05-08Syslog: re-open syslog udp socket on send error (ticket #1477).Vladimir Homutov1-5/+1
Previously, only unix domain sockets were reopened to tolerate cases when local syslog server was restarted. It makes sense to treat other cases (for example, local IP address changes) similarly.
2018-04-18Version bump.Maxim Dounin1-2/+2
2018-04-05Version bump.Maxim Dounin1-2/+2
2018-04-02Core: fixed build, broken by 63e91f263a49.Vladimir Homutov1-16/+16
Both Solaris and Windows define "s_addr" as a macro.
2018-04-02Core: revised the PROXY protocol v2 code.Ruslan Ermilov1-85/+69
- use normal prefixes for types and macros - removed some macros and types - revised debug messages - removed useless check of ngx_sock_ntop() returning 0 - removed special processing of AF_UNSPEC
2018-03-27Core: style.Vladimir Homutov1-15/+14
2018-03-22Core: added processing of version 2 of the PROXY protocol.Vladimir Homutov1-0/+192
The protocol used on inbound connection is auto-detected and corresponding parser is used to extract passed addresses. TLV parameters are ignored. The maximum supported size of PROXY protocol header is 107 bytes (similar to version 1).
2018-03-22Improved code readability (closes #1512).Ruslan Ermilov1-2/+2
2018-03-22Version bump.Maxim Dounin1-2/+2
2018-03-01Core: ngx_current_msec now uses monotonic time if available.Maxim Dounin1-1/+29
When clock_gettime(CLOCK_MONOTONIC) (or faster variants, _FAST on FreeBSD, and _COARSE on Linux) is available, we now use it for ngx_current_msec. This should improve handling of timers if system time changes (ticket #189).
2018-02-21Version bump.Ruslan Ermilov1-2/+2
2018-02-15Core: added a stub for additional zone configuration.Vladimir Homutov1-0/+1
2017-12-30Version bump.Maxim Dounin1-2/+2
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).