Module Name: src
Committed By: christos
Date: Tue Oct 8 15:09:51 UTC 2013
Modified Files:
src/sys/kern: uipc_usrreq.c
Log Message:
- Instead of having accept(2) return a zero-filled sockaddr for the case
where accept(2) was called on a unix socket that called connect(2) and
then close(2), before the connection was accepted, return the empty
sockaddr_un.
- Fix the length of the empty sockaddr_un socket so that it reflects reality.
To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/sys/kern/uipc_usrreq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/uipc_usrreq.c
diff -u src/sys/kern/uipc_usrreq.c:1.144 src/sys/kern/uipc_usrreq.c:1.145
--- src/sys/kern/uipc_usrreq.c:1.144 Thu Aug 29 13:49:21 2013
+++ src/sys/kern/uipc_usrreq.c Tue Oct 8 11:09:51 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.144 2013/08/29 17:49:21 rmind Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.145 2013/10/08 15:09:51 christos Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.144 2013/08/29 17:49:21 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.145 2013/10/08 15:09:51 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -165,7 +165,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.
* that had referenced it have also been destroyed.
*/
const struct sockaddr_un sun_noname = {
- .sun_len = sizeof(sun_noname),
+ .sun_len = offsetof(struct sockaddr_un, sun_path),
.sun_family = AF_LOCAL,
};
ino_t unp_ino; /* prototype for fake inode numbers */
@@ -438,8 +438,14 @@ uipc_usrreq(struct socket *so, int req,
* after it's been accepted. This prevents a client from
* overrunning a server and receiving ECONNREFUSED.
*/
- if (unp->unp_conn == NULL)
+ if (unp->unp_conn == NULL) {
+ /*
+ * This will use the empty socket and will not
+ * allocate.
+ */
+ unp_setaddr(so, nam, true);
break;
+ }
so2 = unp->unp_conn->unp_socket;
if (so2->so_state & SS_ISCONNECTING) {
KASSERT(solocked2(so, so->so_head));