[PATCH] QUIC: better sockaddr initialization
Roman Arutyunyan
arut at nginx.com
Sun May 21 09:06:59 UTC 2023
Hi,
On Sun, May 21, 2023 at 04:42:30AM +0300, Maxim Dounin wrote:
> # HG changeset patch
> # User Maxim Dounin <mdounin at mdounin.ru>
> # Date 1684633125 -10800
> # Sun May 21 04:38:45 2023 +0300
> # Node ID 68fa4b86ed46138dd1a8fcf2cfd80206de068bec
> # Parent 235d482ef6bc8c40a956b2413865d42c94e0fc05
> QUIC: better sockaddr initialization.
>
> The qsock->sockaddr field is a ngx_sockaddr_t union, and therefore can hold
> any sockaddr (and union members, such qsock->sockaddr.sockaddr, can be used
> to access appropriate variant of the sockaddr). It is better to set it via
> qsock->sockaddr itself though, and not qsock->sockaddr.sockaddr, so static
> analyzers won't complain about out-of-bounds access.
>
> Prodded by Coverity (CID 1530403).
>
> diff --git a/src/event/quic/ngx_event_quic_udp.c b/src/event/quic/ngx_event_quic_udp.c
> --- a/src/event/quic/ngx_event_quic_udp.c
> +++ b/src/event/quic/ngx_event_quic_udp.c
> @@ -183,7 +183,7 @@ ngx_quic_recvmsg(ngx_event_t *ev)
>
> qsock = ngx_quic_get_socket(c);
>
> - ngx_memcpy(&qsock->sockaddr.sockaddr, sockaddr, socklen);
> + ngx_memcpy(&qsock->sockaddr, sockaddr, socklen);
> qsock->socklen = socklen;
>
> c->udp->buffer = &buf;
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx-devel
Looks good
More information about the nginx-devel
mailing list