summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-09 00:04:17 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-09 00:04:17 +0000
commit18eff6bb082eee1ed861a997ea92b93a3f473ab5 (patch)
tree264405def6a0eb687f07852a4d497f049c86a3fe /sys/kern
parentf56830a1e5897b0172a0452fc7e4a7ca2208a34b (diff)
return error from soaccept() upwards. part of accept(2) fix against RST
right after handshake.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_syscalls.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 33ddae83b58..a88b971cc6f 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.34 2000/11/16 20:02:19 provos Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.35 2001/02/09 00:04:16 itojun Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -211,8 +211,8 @@ sys_accept(p, v, retval)
fp->f_ops = &socketops;
fp->f_data = (caddr_t)so;
nam = m_get(M_WAIT, MT_SONAME);
- (void) soaccept(so, nam);
- if (SCARG(uap, name)) {
+ error = soaccept(so, nam);
+ if (!error && SCARG(uap, name)) {
if (namelen > nam->m_len)
namelen = nam->m_len;
/* SHOULD COPY OUT A CHAIN HERE */
@@ -222,6 +222,11 @@ sys_accept(p, v, retval)
(caddr_t)SCARG(uap, anamelen),
sizeof (*SCARG(uap, anamelen)));
}
+ /* if an error occured, free the file descriptor */
+ if (error) {
+ fdremove(p->p_fd, tmpfd);
+ ffree(fp);
+ }
m_freem(nam);
splx(s);
return (error);