Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
bgpd: properly handle named ports
To:
tech@openbsd.org
Date:
Tue, 12 May 2026 16:50:26 +0200

Download raw body.

Thread
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.

-- 
: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