Welcome! Log In Create A New Profile

Advanced

[nginx] Stream: fixed processing of zero length UDP packets (ticket #1982).

Vladimir Homutov
June 09, 2020 03:06PM
details: https://hg.nginx.org/nginx/rev/d127837c714f
branches:
changeset: 7665:d127837c714f
user: Vladimir Homutov <vl@nginx.com>
date: Mon Jun 08 11:40:34 2020 +0300
description:
Stream: fixed processing of zero length UDP packets (ticket #1982).

diffstat:

src/os/unix/ngx_udp_sendmsg_chain.c | 7 +++++++
src/stream/ngx_stream_proxy_module.c | 3 ++-
src/stream/ngx_stream_write_filter_module.c | 3 ++-
3 files changed, 11 insertions(+), 2 deletions(-)

diffs (50 lines):

diff -r 699f6e55bbb4 -r d127837c714f src/os/unix/ngx_udp_sendmsg_chain.c
--- a/src/os/unix/ngx_udp_sendmsg_chain.c Wed Jun 03 19:11:32 2020 +0300
+++ b/src/os/unix/ngx_udp_sendmsg_chain.c Mon Jun 08 11:40:34 2020 +0300
@@ -189,6 +189,13 @@ ngx_udp_output_chain_to_iovec(ngx_iovec_
return cl;
}

+ /* zero-sized datagram; pretend to have at least 1 iov */
+ if (n == 0) {
+ iov = &vec->iovs[n++];
+ iov->iov_base = NULL;
+ iov->iov_len = 0;
+ }
+
vec->count = n;
vec->size = total;

diff -r 699f6e55bbb4 -r d127837c714f src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c Wed Jun 03 19:11:32 2020 +0300
+++ b/src/stream/ngx_stream_proxy_module.c Mon Jun 08 11:40:34 2020 +0300
@@ -839,7 +839,7 @@ ngx_stream_proxy_init_upstream(ngx_strea
u->upstream_buf.last = p;
}

- if (c->buffer && c->buffer->pos < c->buffer->last) {
+ if (c->buffer && c->buffer->pos <= c->buffer->last) {
ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0,
"stream proxy add preread buffer: %uz",
c->buffer->last - c->buffer->pos);
@@ -853,6 +853,7 @@ ngx_stream_proxy_init_upstream(ngx_strea
*cl->buf = *c->buffer;

cl->buf->tag = (ngx_buf_tag_t) &ngx_stream_proxy_module;
+ cl->buf->temporary = (cl->buf->pos == cl->buf->last) ? 0 : 1;
cl->buf->flush = 1;

cl->next = u->upstream_out;
diff -r 699f6e55bbb4 -r d127837c714f src/stream/ngx_stream_write_filter_module.c
--- a/src/stream/ngx_stream_write_filter_module.c Wed Jun 03 19:11:32 2020 +0300
+++ b/src/stream/ngx_stream_write_filter_module.c Mon Jun 08 11:40:34 2020 +0300
@@ -234,7 +234,8 @@ ngx_stream_write_filter(ngx_stream_sessi

if (size == 0
&& !(c->buffered & NGX_LOWLEVEL_BUFFERED)
- && !(last && c->need_last_buf))
+ && !(last && c->need_last_buf)
+ && !(c->type == SOCK_DGRAM && flush))
{
if (last || flush || sync) {
for (cl = *out; cl; /* void */) {
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Stream: fixed processing of zero length UDP packets (ticket #1982).

Vladimir Homutov 123 June 09, 2020 03:06PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 62
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready