[PATCH] bsd/ntpq: Use the correct address length

Chris Johns chrisj at rtems.org
Fri Sep 22 00:02:37 UTC 2023


I assume this is in the network services repo?

OK and thanks

Chris

On 22/9/2023 4:38 am, Kinsey Moore wrote:
> lwIP includes more than the bare address structures in its accounting of
> the total addrinfo struct size. Ensure that lwIP gets the correct
> address size.
> ---
>  bsd/freebsd/contrib/ntp/ntpq/ntpq.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/bsd/freebsd/contrib/ntp/ntpq/ntpq.c b/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
> index 1cea922..0ea6c08 100644
> --- a/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
> +++ b/bsd/freebsd/contrib/ntp/ntpq/ntpq.c
> @@ -828,6 +828,14 @@ openhost(
>  #ifdef SYS_VXWORKS
>  	   (connect(sockfd, (struct sockaddr *)&hostaddr,
>  		    sizeof(hostaddr)) == -1)
> +#elif defined(__rtems__)
> +	   /*
> +	    * lwIP's ai_addrlen covers the entire struct which includes
> +	    * padding for extra data and is not accurate for calls which
> +	    * validate the size of the address structure. Use sa_len instead
> +	    */
> +	   (connect(sockfd, (struct sockaddr *)ai->ai_addr,
> +		ai->ai_addr->sa_len) == -1)
>  #else
>  	   (connect(sockfd, (struct sockaddr *)ai->ai_addr,
>  		ai->ai_addrlen) == -1)


More information about the devel mailing list