Source-Changes-HG archive

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

[src/trunk]: src/sys/kern make bind() fail with EINVAL if the address family ...



details:   https://anonhg.NetBSD.org/src/rev/6159dda830ad
branches:  trunk
changeset: 807308:6159dda830ad
user:      rtr <rtr%NetBSD.org@localhost>
date:      Sun Apr 05 02:26:39 2015 +0000

description:
make bind() fail with EINVAL if the address family of the provided
socket does not match the address family of the sockaddr received.

diffstat:

 sys/kern/uipc_socket.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 91ba1e802cbc -r 6159dda830ad sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Sat Apr 04 19:32:06 2015 +0000
+++ b/sys/kern/uipc_socket.c    Sun Apr 05 02:26:39 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $    */
+/*     $NetBSD: uipc_socket.c,v 1.237 2015/04/05 02:26:39 rtr Exp $    */
 
 /*-
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.236 2015/04/03 20:01:07 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.237 2015/04/05 02:26:39 rtr Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -629,6 +629,10 @@
        int     error;
 
        solock(so);
+       if (nam->sa_family != so->so_proto->pr_domain->dom_family) {
+               sounlock(so);
+               return EINVAL;
+       }
        error = (*so->so_proto->pr_usrreqs->pr_bind)(so, nam, l);
        sounlock(so);
        return error;



Home | Main Index | Thread Index | Old Index