Welcome! Log In Create A New Profile

Advanced

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

Maxim Dounin
November 08, 2022 04:50AM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1667900901 -10800
# Tue Nov 08 12:48:21 2022 +0300
# Node ID 42bc158a47ecb3c2bd0396c723c307c757f2770e
# Parent 251daa98cc87111a62375941c988ed969f5d50dc
Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().

diff --git a/src/core/ngx_proxy_protocol.c b/src/core/ngx_proxy_protocol.c
--- a/src/core/ngx_proxy_protocol.c
+++ b/src/core/ngx_proxy_protocol.c
@@ -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

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

Maxim Dounin 132 November 08, 2022 04:50AM

Re: [PATCH] Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp()

Alejandro Colomar 30 November 08, 2022 05:44AM



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

Online Users

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