Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys PR/47738: connect(2) to 239.x.y.z should return error bu...



details:   https://anonhg.NetBSD.org/src/rev/711f3664a5f1
branches:  trunk
changeset: 786062:711f3664a5f1
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 12 21:30:40 2013 +0000

description:
PR/47738: connect(2) to 239.x.y.z should return error but does not.

diffstat:

 sys/netinet/in_pcb.c   |  9 +++++++--
 sys/netinet6/in6_pcb.c |  8 ++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 24c4d2672ca8 -r 711f3664a5f1 sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c      Fri Apr 12 20:02:00 2013 +0000
+++ b/sys/netinet/in_pcb.c      Fri Apr 12 21:30:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_pcb.c,v 1.143 2012/06/25 15:28:39 christos Exp $    */
+/*     $NetBSD: in_pcb.c,v 1.144 2013/04/12 21:30:40 christos Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.143 2012/06/25 15:28:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.144 2013/04/12 21:30:40 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -470,6 +470,11 @@
                return (EAFNOSUPPORT);
        if (sin->sin_port == 0)
                return (EADDRNOTAVAIL);
+
+       if (IN_MULTICAST(sin->sin_addr.s_addr) &&
+           inp->inp_socket->so_type == SOCK_STREAM)
+               return EADDRNOTAVAIL;
+
        if (TAILQ_FIRST(&in_ifaddrhead) != 0) {
                /*
                 * If the destination address is INADDR_ANY,
diff -r 24c4d2672ca8 -r 711f3664a5f1 sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c    Fri Apr 12 20:02:00 2013 +0000
+++ b/sys/netinet6/in6_pcb.c    Fri Apr 12 21:30:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_pcb.c,v 1.121 2012/08/24 06:03:18 dholland Exp $   */
+/*     $NetBSD: in6_pcb.c,v 1.122 2013/04/12 21:30:40 christos Exp $   */
 /*     $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $        */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.121 2012/08/24 06:03:18 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.122 2013/04/12 21:30:40 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -452,6 +452,10 @@
        if (sin6->sin6_port == 0)
                return (EADDRNOTAVAIL);
 
+       if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) &&
+           in6p->in6p_socket->so_type == SOCK_STREAM)
+               return EADDRNOTAVAIL;
+
        if (sin6->sin6_scope_id == 0 && !ip6_use_defzone)
                scope_ambiguous = 1;
        if ((error = sa6_embedscope(sin6, ip6_use_defzone)) != 0)



Home | Main Index | Thread Index | Old Index