raw ip: clear sin_port on bind(2)

Application may set sin_port to some value.  Although this value is not
used by SOCK_RAW, it breaks a check that the address is available.  A
perfect fix would be not use sockaddrs for ifaddrs, but that would be a
bigger change.

PR:			298366
Reviewed by:		pouria, bnovkov, adrian
Differential Revision:	https://reviews.freebsd.org/D59570
Fixes:			948ad32ae1
This commit is contained in:
Gleb Smirnoff committed 2026-09-12 05:12:36 -07:00
1 parent a1e236e9d6
commit 465942e8cc
1 file changed
+1 -1
+1 -1
View File
@@ -876,7 +876,7 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
fib = V_rip_bind_all_fibs == 0 ? inp->inp_inc.inc_fibnum :
RT_ALL_FIBS;
addr->sin_port = 0;
if (CK_STAILQ_EMPTY(&V_ifnet) ||
(addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
(addr->sin_addr.s_addr &&