Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: properly handle named ports
To:
tech@openbsd.org
Date:
Tue, 12 May 2026 17:03:30 +0200

Download raw body.

Thread
On Tue, May 12, 2026 at 04:50:26PM +0200, Claudio Jeker wrote:
> It is possible to use ports by name, bgpd will then call getservice()
> which is a wrapper around getservbyname(). The problem is that s->s_port
> returned by getservbyname() is in network byte order but the code around
> this expects it to be host byte order. So lets add a ntohs() here.

ok tb

> 
> -- 
> :wq Claudio
> 
> Index: parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> diff -u -p -r1.493 parse.y
> --- parse.y	11 May 2026 18:41:06 -0000	1.493
> +++ parse.y	12 May 2026 14:46:44 -0000
> @@ -5625,7 +5625,7 @@ getservice(char *n)
>  		s = getservbyname(n, "udp");
>  	if (s == NULL)
>  		return -1;
> -	return s->s_port;
> +	return ntohs(s->s_port);
>  }
>  
>  static int
>