Check that sa_len is the appropriate value in tcp_usr_bind(),

tcp6_usr_bind(), tcp_usr_connect(), and tcp6_usr_connect() before checking
to see whether the address is multicast so that the proper errno value
will be returned if sa_len is incorrect.  The checks are identical to the
ones in in_pcbbind_setup(), in6_pcbbind(), and in6_pcbladdr(), which are
called after the multicast address check passes.

MFC after:	30 days
This commit is contained in:
Don Lewis 2004-01-10 08:53:00 +00:00
parent 2b77864f1e
commit e29ef13f6c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124336

View File

@ -244,6 +244,8 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
* to them.
*/
sinp = (struct sockaddr_in *)nam;
if (nam->sa_len != sizeof (*sinp))
return (EINVAL);
if (sinp->sin_family == AF_INET &&
IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
error = EAFNOSUPPORT;
@ -273,6 +275,8 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
* to them.
*/
sin6p = (struct sockaddr_in6 *)nam;
if (nam->sa_len != sizeof (*sin6p))
return (EINVAL);
if (sin6p->sin6_family == AF_INET6 &&
IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr)) {
error = EAFNOSUPPORT;
@ -366,6 +370,8 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
* Must disallow TCP ``connections'' to multicast addresses.
*/
sinp = (struct sockaddr_in *)nam;
if (nam->sa_len != sizeof (*sinp))
return (EINVAL);
if (sinp->sin_family == AF_INET
&& IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
error = EAFNOSUPPORT;
@ -398,6 +404,8 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
* Must disallow TCP ``connections'' to multicast addresses.
*/
sin6p = (struct sockaddr_in6 *)nam;
if (nam->sa_len != sizeof (*sin6p))
return (EINVAL);
if (sin6p->sin6_family == AF_INET6
&& IN6_IS_ADDR_MULTICAST(&sin6p->sin6_addr)) {
error = EAFNOSUPPORT;