Author: kevans
Date: Sun Sep 13 02:17:57 2020
New Revision: 365684
URL: https://svnweb.freebsd.org/changeset/base/365684

Log:
  MFS r365682: getlogin_r: fix the type of len
  
  getlogin_r is specified by POSIX to to take a size_t len, not int. Fix our
  version to do the same, bump the symbol version due to ABI change and
  provide compat.
  
  This was reported to break compilation of Ruby 2.8.
  
  Some discussion about the necessity of the ABI compat did take place in the
  review. While many 64-bit platforms would likely be passing it in a 64-bit
  register and zero-extended and thus, not notice ABI breakage, some do
  sign-extend (e.g. mips).
  
  PR:           247102
  Approved by:  re (gjb)

Modified:
  releng/12.2/include/unistd.h
  releng/12.2/lib/libc/gen/Symbol.map
  releng/12.2/lib/libc/gen/getlogin.c
  releng/12.2/lib/libc/sys/getlogin.2
Directory Properties:
  releng/12.2/   (props changed)

Modified: releng/12.2/include/unistd.h
==============================================================================
--- releng/12.2/include/unistd.h        Sun Sep 13 02:17:17 2020        
(r365683)
+++ releng/12.2/include/unistd.h        Sun Sep 13 02:17:57 2020        
(r365684)
@@ -399,7 +399,7 @@ int  ftruncate(int, off_t);
 #endif
 
 #if __POSIX_VISIBLE >= 199506
-int     getlogin_r(char *, int);
+int     getlogin_r(char *, size_t);
 #endif
 
 /* 1003.1-2001 */

Modified: releng/12.2/lib/libc/gen/Symbol.map
==============================================================================
--- releng/12.2/lib/libc/gen/Symbol.map Sun Sep 13 02:17:17 2020        
(r365683)
+++ releng/12.2/lib/libc/gen/Symbol.map Sun Sep 13 02:17:57 2020        
(r365684)
@@ -156,7 +156,6 @@ FBSD_1.0 {
        gethostname;
        getloadavg;
        getlogin;
-       getlogin_r;
        setnetgrent;
        getnetgrent;
        endnetgrent;
@@ -423,6 +422,7 @@ FBSD_1.5 {
 
 FBSD_1.6 {
        __sysctlbyname;
+       getlogin_r;
        memalign;
        scandir_b;
        sigandset;

Modified: releng/12.2/lib/libc/gen/getlogin.c
==============================================================================
--- releng/12.2/lib/libc/gen/getlogin.c Sun Sep 13 02:17:17 2020        
(r365683)
+++ releng/12.2/lib/libc/gen/getlogin.c Sun Sep 13 02:17:57 2020        
(r365684)
@@ -58,7 +58,7 @@ getlogin(void)
 }
 
 int
-getlogin_r(char *logname, int namelen)
+getlogin_r(char *logname, size_t namelen)
 {
        char tmpname[MAXLOGNAME];
        int     len;
@@ -75,3 +75,13 @@ getlogin_r(char *logname, int namelen)
        strlcpy(logname, tmpname, len);
        return (0);
 }
+
+/* FreeBSD 12 and earlier compat. */
+int
+__getlogin_r_fbsd12(char *logname, int namelen)
+{
+       if (namelen < 1)
+               return (ERANGE);
+       return (getlogin_r(logname, namelen));
+}
+__sym_compat(getlogin_r, __getlogin_r_fbsd12, FBSD_1.0);

Modified: releng/12.2/lib/libc/sys/getlogin.2
==============================================================================
--- releng/12.2/lib/libc/sys/getlogin.2 Sun Sep 13 02:17:17 2020        
(r365683)
+++ releng/12.2/lib/libc/sys/getlogin.2 Sun Sep 13 02:17:57 2020        
(r365684)
@@ -28,7 +28,7 @@
 .\"    @(#)getlogin.2  8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd June 9, 1993
+.Dd September 9, 2020
 .Dt GETLOGIN 2
 .Os
 .Sh NAME
@@ -44,7 +44,7 @@
 .Fn getlogin void
 .In sys/param.h
 .Ft int
-.Fn getlogin_r "char *name" "int len"
+.Fn getlogin_r "char *name" "size_t len"
 .Ft int
 .Fn setlogin "const char *name"
 .Sh DESCRIPTION
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to