From owner-svn-src-head@freebsd.org Fri Feb 23 00:28:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD56BF1299A; Fri, 23 Feb 2018 00:28:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 836BF8173F; Fri, 23 Feb 2018 00:28:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7A18B72CD; Fri, 23 Feb 2018 00:28:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1N0S0du042023; Fri, 23 Feb 2018 00:28:00 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1N0S0Ef042022; Fri, 23 Feb 2018 00:28:00 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201802230028.w1N0S0Ef042022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Fri, 23 Feb 2018 00:28:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329846 - head/lib/libc/gen X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/lib/libc/gen X-SVN-Commit-Revision: 329846 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Feb 2018 00:28:01 -0000 Author: pfg Date: Fri Feb 23 00:28:00 2018 New Revision: 329846 URL: https://svnweb.freebsd.org/changeset/base/329846 Log: getpeereid(3): Fix behavior on failure to match documentation. According to the getpeereid(3) documentation, on failure the value -1 is returned and the global variable errno is set to indicate the error. We were returning the error instead. Obtained from: Apple's Libc-1244.30.3 MFC after: 5 days Modified: head/lib/libc/gen/getpeereid.c Modified: head/lib/libc/gen/getpeereid.c ============================================================================== --- head/lib/libc/gen/getpeereid.c Fri Feb 23 00:17:50 2018 (r329845) +++ head/lib/libc/gen/getpeereid.c Fri Feb 23 00:28:00 2018 (r329846) @@ -50,8 +50,10 @@ getpeereid(int s, uid_t *euid, gid_t *egid) error = _getsockopt(s, 0, LOCAL_PEERCRED, &xuc, &xuclen); if (error != 0) return (error); - if (xuc.cr_version != XUCRED_VERSION) - return (EINVAL); + if (xuc.cr_version != XUCRED_VERSION) { + errno = EINVAL; + return (-1); + } *euid = xuc.cr_uid; *egid = xuc.cr_gid; return (0);