diff options
-rw-r--r-- | sys/netinet/sctputil.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 74a0f64..f68f2d5 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5831,8 +5831,18 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp, if (assoc_id == 0) { /* add the address */ struct sctp_inpcb *lep; + struct sockaddr_in *lsin = (struct sockaddr_in *)addr_touse; + + /* validate the incoming port */ + if ((lsin->sin_port != 0) && + (lsin->sin_port != inp->sctp_lport)) { + *error = EINVAL; + return; + } else { + /* user specified 0 port, set it to existing port */ + lsin->sin_port = inp->sctp_lport; + } - ((struct sockaddr_in *)addr_touse)->sin_port = inp->sctp_lport; lep = sctp_pcb_findep(addr_touse, 1, 0, vrf_id); if (lep != NULL) { /* |