Date: Thu, 08 Feb 2001 10:39:56 +0900 From: itojun@iijlab.net To: Jonathan Lemon <jlemon@flugsvamp.com>, kris@obsecurity.org, net@freebsd.org Subject: Re: [itojun@iijlab.net: accept(2) behavior with tcp RST right after handshake] Message-ID: <9722.981596396@coconut.itojun.org> In-Reply-To: itojun's message of Thu, 08 Feb 2001 10:33:29 JST. <9619.981596009@coconut.itojun.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>>>Looks good to me (although the patch is mixed in with a bunch >>>of other crud). I've tested it out locally and will commit it >>>unless there are any objections. >> it is because of cvs issue. the important portion is below. > oops, need some change in uipc_syscalls.c side... hold on. this diff is taken against 4.2-RELEASE (in kame tree), sorry. also i need to say that i ran no tests (i have no environment). uipc_syscalls.c change: make very sure to nuke file descriptor on errors uipc_socket.c change: return ECONNABORTED itojun Index: kern/uipc_socket.c =================================================================== RCS file: /cvsroot/kame/kame/freebsd4/sys/kern/uipc_socket.c,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -r1.1.1.3 -r1.3 --- kern/uipc_socket.c 2001/01/19 02:25:59 1.1.1.3 +++ kern/uipc_socket.c 2001/02/08 01:37:42 1.3 @@ -362,7 +362,7 @@ else { if (nam) *nam = 0; - error = 0; + error = ECONNABORTED; } splx(s); return (error); Index: kern/uipc_syscalls.c =================================================================== RCS file: /cvsroot/kame/kame/freebsd4/sys/kern/uipc_syscalls.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -r1.1.1.3 -r1.2 --- kern/uipc_syscalls.c 2001/01/19 02:26:00 1.1.1.3 +++ kern/uipc_syscalls.c 2001/02/08 01:37:42 1.2 @@ -270,28 +270,22 @@ fp->f_ops = &socketops; fp->f_type = DTYPE_SOCKET; sa = 0; - (void) soaccept(so, &sa); - if (sa == 0) { - namelen = 0; - if (uap->name) - goto gotnoname; - splx(s); - return 0; - } - if (uap->name) { + error = soaccept(so, &sa); + if (!error && uap->name) { /* check sa_len before it is destroyed */ - if (namelen > sa->sa_len) - namelen = sa->sa_len; + if (sa) { + if (namelen > sa->sa_len) + namelen = sa->sa_len; #ifdef COMPAT_OLDSOCK - if (compat) - ((struct osockaddr *)sa)->sa_family = - sa->sa_family; + if (compat) + ((struct osockaddr *)sa)->sa_family = + sa->sa_family; #endif - error = copyout(sa, (caddr_t)uap->name, (u_int)namelen); - if (!error) -gotnoname: - error = copyout((caddr_t)&namelen, - (caddr_t)uap->anamelen, sizeof (*uap->anamelen)); + error = copyout(sa, (caddr_t)uap->name, (u_int)namelen); + } else + namelen = 0; + error = copyout((caddr_t)&namelen, + (caddr_t)uap->anamelen, sizeof (*uap->anamelen)); } if (sa) FREE(sa, M_SONAME); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9722.981596396>