Author: pfg
Date: Wed Feb 28 02:39:38 2018
New Revision: 330095
URL: https://svnweb.freebsd.org/changeset/base/330095

Log:
  MFC r329846:
  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

Modified:
  stable/10/lib/libc/gen/getpeereid.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/getpeereid.c
==============================================================================
--- stable/10/lib/libc/gen/getpeereid.c Wed Feb 28 02:37:59 2018        
(r330094)
+++ stable/10/lib/libc/gen/getpeereid.c Wed Feb 28 02:39:38 2018        
(r330095)
@@ -46,8 +46,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);
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to