[PATCH] Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp()
Alejandro Colomar
alx.manpages at gmail.com
Tue Nov 8 10:41:58 UTC 2022
Hi Maxim!
On 11/8/22 10:48, Maxim Dounin wrote:
> # HG changeset patch
> # User Maxim Dounin <mdounin at 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().
LGTM.
If you use these:
Reviewed-by: Alejandro Colomar <alx at nginx.com>
Cheers,
Alex
>
> 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 at nginx.org
> To unsubscribe send an email to nginx-devel-leave at nginx.org
--
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20221108/bea8841c/attachment.bin>
More information about the nginx-devel
mailing list