Date: Sun, 11 May 2014 21:21:15 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265896 - head/sys/kern Message-ID: <201405112121.s4BLLFAA099777@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun May 11 21:21:14 2014 New Revision: 265896 URL: http://svnweb.freebsd.org/changeset/base/265896 Log: accept(),accept4(): Don't set *addrlen = 0 on [ECONNABORTED]. If the underlying protocol reported an error (e.g. because a connection was closed while waiting in the queue), this error was also indicated by returning a zero-length address. For all other kinds of errors (e.g. [EAGAIN], [ENFILE], [EMFILE]), *addrlen is unmodified and there are successful cases where a zero-length address is returned (e.g. a connection from an unbound Unix-domain socket), so this error indication is not reliable. As reported in Austin Group bug #836, modifying *addrlen on error may cause subtle bugs if applications retry the call without resetting *addrlen. Modified: head/sys/kern/uipc_syscalls.c Modified: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Sun May 11 21:07:00 2014 (r265895) +++ head/sys/kern/uipc_syscalls.c Sun May 11 21:21:14 2014 (r265896) @@ -414,14 +414,8 @@ accept1(td, s, uname, anamelen, flags) error = kern_accept4(td, s, &name, &namelen, flags, &fp); - /* - * return a namelen of zero for older code which might - * ignore the return value from accept. - */ - if (error != 0) { - (void) copyout(&namelen, anamelen, sizeof(*anamelen)); + if (error != 0) return (error); - } if (error == 0 && uname != NULL) { #ifdef COMPAT_OLDSOCK @@ -555,15 +549,8 @@ kern_accept4(struct thread *td, int s, s (void) fo_ioctl(nfp, FIOASYNC, &tmp, td->td_ucred, td); sa = 0; error = soaccept(so, &sa); - if (error != 0) { - /* - * return a namelen of zero for older code which might - * ignore the return value from accept. - */ - if (name) - *namelen = 0; + if (error != 0) goto noconnection; - } if (sa == NULL) { if (name) *namelen = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405112121.s4BLLFAA099777>