From owner-svn-src-all@FreeBSD.ORG Sun May 11 21:21:15 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7AC89B05; Sun, 11 May 2014 21:21:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 685BA2749; Sun, 11 May 2014 21:21:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4BLLFnJ099779; Sun, 11 May 2014 21:21:15 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4BLLFAA099777; Sun, 11 May 2014 21:21:15 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201405112121.s4BLLFAA099777@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 11 May 2014 21:21:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265896 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 May 2014 21:21:15 -0000 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;