Opened 6 years ago

Closed 6 years ago

#1582 closed defect (invalid)

func ngx_proxy_protocol_read encounter an incomplete line

Reported by: njuzpw@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.12.x
Keywords: proxy protocol incomplete line Cc:
uname -a: 2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.1
built by clang 7.3.0 (clang-703.0.31)
configure arguments: --with-stream --prefix=output

Description

when I read the source code of nginx, i found this in file :http/ngx_http_request.c

if we set proxy_protol like this:
[listen 80 proxy_protocol;],

and then in func ngx_http_wait_request_handler, we will call

n = c->recv(c, b->last, size);
....
p = ngx_proxy_protocol_read(c, b->pos, b->last);

to see if this is an legal proxy_protocol message.

there is condition that if data in b is not an complete line of proxy_protocol message, ngx_proxy_protocol_read will set p to NULL instead of adding rev to event loop, and this will case a failure.

I'm wondering if is reasonable here to read proxy_protocol message only once for we may get an incomplete line and case an error(I have tried and it failed indeed)

Change History (1)

comment:1 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: newclosed

Quoting PROXY protocol specification:

A receiver may reject an incomplete line which does not
contain the CRLF sequence in the first atomic read operation.

That's what nginx does, and this is in line with the specification.

Note: See TracTickets for help on using tickets.