[nginx] Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp().
Sergey Kandaurov
pluknet at nginx.com
Mon Nov 21 15:29:36 UTC 2022
details: https://hg.nginx.org/nginx/rev/42bc158a47ec
branches:
changeset: 8101:42bc158a47ec
user: Maxim Dounin <mdounin at 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);
More information about the nginx-devel
mailing list