diff options
author | paul <paul@FreeBSD.org> | 2000-05-02 23:53:46 +0000 |
---|---|---|
committer | paul <paul@FreeBSD.org> | 2000-05-02 23:53:46 +0000 |
commit | 718dc1ac42644978b96ed6d2458c4b013e642599 (patch) | |
tree | f9c5a0894350079f2c307e9b1c359cdc0ec74eb9 /sys/netinet/ip_divert.c | |
parent | f1e9c5e1a77b6de2ba7d18c010c9ed46a538bc24 (diff) | |
download | FreeBSD-src-718dc1ac42644978b96ed6d2458c4b013e642599.zip FreeBSD-src-718dc1ac42644978b96ed6d2458c4b013e642599.tar.gz |
Force the address of the socket to be INADDR_ANY immediately before
calling in_pcbbind so that in_pcbbind sees a valid address if no
address was specified (since divert sockets ignore them).
PR: 17552
Reviewed by: Brian
Diffstat (limited to 'sys/netinet/ip_divert.c')
-rw-r--r-- | sys/netinet/ip_divert.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 6506c8e..bbe5036 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -406,7 +406,19 @@ div_bind(struct socket *so, struct sockaddr *nam, struct proc *p) s = splnet(); inp = sotoinpcb(so); - error = in_pcbbind(inp, nam, p); + /* in_pcbbind assumes that the socket is a sockaddr_in + * and in_pcbbind requires a valid address. Since divert + * sockets don't we need to make sure the address is + * filled in properly. + * XXX -- divert should not be abusing in_pcbind + * and should probably have its own family. + */ + if (nam->sa_family != AF_INET) { + error = EAFNOSUPPORT; + } else { + ((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY; + error = in_pcbbind(inp, nam, p); + } splx(s); return 0; } |