Welcome! Log In Create A New Profile

Advanced

[nginx] Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().

Sergey Kandaurov
November 21, 2022 10:32AM
details: https://hg.nginx.org/nginx/rev/42bc158a47ec
branches:
changeset: 8101:42bc158a47ec
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue Nov 08 12:48:21 2022 +0300
description:
Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().

diffstat:

src/core/ngx_proxy_protocol.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 251daa98cc87 -r 42bc158a47ec src/core/ngx_proxy_protocol.c
--- a/src/core/ngx_proxy_protocol.c Tue Nov 08 12:48:19 2022 +0300
+++ b/src/core/ngx_proxy_protocol.c Tue Nov 08 12:48:21 2022 +0300
@@ -109,7 +109,7 @@ ngx_proxy_protocol_read(ngx_connection_t
len = last - buf;

if (len >= sizeof(ngx_proxy_protocol_header_t)
- && memcmp(p, signature, sizeof(signature) - 1) == 0)
+ && ngx_memcmp(p, signature, sizeof(signature) - 1) == 0)
{
return ngx_proxy_protocol_v2_read(c, buf, last);
}
@@ -396,11 +396,11 @@ ngx_proxy_protocol_v2_read(ngx_connectio

src_sockaddr.sockaddr_in.sin_family = AF_INET;
src_sockaddr.sockaddr_in.sin_port = 0;
- memcpy(&src_sockaddr.sockaddr_in.sin_addr, in->src_addr, 4);
+ ngx_memcpy(&src_sockaddr.sockaddr_in.sin_addr, in->src_addr, 4);

dst_sockaddr.sockaddr_in.sin_family = AF_INET;
dst_sockaddr.sockaddr_in.sin_port = 0;
- memcpy(&dst_sockaddr.sockaddr_in.sin_addr, in->dst_addr, 4);
+ ngx_memcpy(&dst_sockaddr.sockaddr_in.sin_addr, in->dst_addr, 4);

pp->src_port = ngx_proxy_protocol_parse_uint16(in->src_port);
pp->dst_port = ngx_proxy_protocol_parse_uint16(in->dst_port);
@@ -423,11 +423,11 @@ ngx_proxy_protocol_v2_read(ngx_connectio

src_sockaddr.sockaddr_in6.sin6_family = AF_INET6;
src_sockaddr.sockaddr_in6.sin6_port = 0;
- memcpy(&src_sockaddr.sockaddr_in6.sin6_addr, in6->src_addr, 16);
+ ngx_memcpy(&src_sockaddr.sockaddr_in6.sin6_addr, in6->src_addr, 16);

dst_sockaddr.sockaddr_in6.sin6_family = AF_INET6;
dst_sockaddr.sockaddr_in6.sin6_port = 0;
- memcpy(&dst_sockaddr.sockaddr_in6.sin6_addr, in6->dst_addr, 16);
+ ngx_memcpy(&dst_sockaddr.sockaddr_in6.sin6_addr, in6->dst_addr, 16);

pp->src_port = ngx_proxy_protocol_parse_uint16(in6->src_port);
pp->dst_port = ngx_proxy_protocol_parse_uint16(in6->dst_port);
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[nginx] Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().

Sergey Kandaurov 221 November 21, 2022 10:32AM



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

Online Users

Guests: 69
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