aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-09-09 18:07:13 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-09-09 18:07:13 +0000
commit69112cca60cb63495de2550f90162eb1b095a157 (patch)
tree37222cb1fbcb4e94b8311c234bc8ae83e8fb8b0e
parentd455cd5ac36f4c1ac76f04e2c2bb4bfb00fe8bcd (diff)
downloadsrc-69112cca60cb63495de2550f90162eb1b095a157.tar.gz
src-69112cca60cb63495de2550f90162eb1b095a157.zip
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 Submitted by: Bertram Scharpf <software@bertram-scharpf.de> (original) Submitted by: cem (ABI compat) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26335
Notes
Notes: svn path=/head/; revision=365506
-rw-r--r--include/unistd.h2
-rw-r--r--lib/libc/gen/Symbol.map2
-rw-r--r--lib/libc/gen/getlogin.c12
-rw-r--r--lib/libc/sys/getlogin.24
4 files changed, 15 insertions, 5 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 02df2515eaaa..9fa9bebbc4c0 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -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 */
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index e17d74d1a151..718b95e6f82d 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -156,7 +156,6 @@ FBSD_1.0 {
gethostname;
getloadavg;
getlogin;
- getlogin_r;
setnetgrent;
getnetgrent;
endnetgrent;
@@ -422,6 +421,7 @@ FBSD_1.5 {
};
FBSD_1.6 {
+ getlogin_r;
memalign;
scandir_b;
sigandset;
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index 3a07ca36bca7..a8bc2fd0688f 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -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);
diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2
index a0c1dd82024b..2d82aea92aa5 100644
--- a/lib/libc/sys/getlogin.2
+++ b/lib/libc/sys/getlogin.2
@@ -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