Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Feb 2018 00:28:00 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329846 - head/lib/libc/gen
Message-ID:  <201802230028.w1N0S0Ef042022@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802230028.w1N0S0Ef042022>