Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern - Instead of having accept(2) return a zero-filled ...
details: https://anonhg.NetBSD.org/src/rev/8b9cf274dcc1
branches: trunk
changeset: 790429:8b9cf274dcc1
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 08 15:09:51 2013 +0000
description:
- 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.
diffstat:
sys/kern/uipc_usrreq.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (43 lines):
diff -r f7b01ae8ee47 -r 8b9cf274dcc1 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Tue Oct 08 14:54:29 2013 +0000
+++ b/sys/kern/uipc_usrreq.c Tue Oct 08 15:09:51 2013 +0000
@@ -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 @@
* 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 @@
* 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));
Home |
Main Index |
Thread Index |
Old Index