Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/lib/libcompat/4.4 Pull up revision 1.7 (requested by luke...



details:   https://anonhg.NetBSD.org/src/rev/876e63012d85
branches:  netbsd-3
changeset: 576522:876e63012d85
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Jul 09 22:52:32 2005 +0000

description:
Pull up revision 1.7 (requested by lukem in ticket #535):
Use getpwuid_r, KNF. From John Nemeth, many thanks.

diffstat:

 lib/libcompat/4.4/cuserid.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (42 lines):

diff -r 61a744c87fcc -r 876e63012d85 lib/libcompat/4.4/cuserid.c
--- a/lib/libcompat/4.4/cuserid.c       Sat Jul 09 22:52:26 2005 +0000
+++ b/lib/libcompat/4.4/cuserid.c       Sat Jul 09 22:52:32 2005 +0000
@@ -32,7 +32,7 @@
 #if 0
 static char sccsid[] = "@(#)cuserid.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: cuserid.c,v 1.6 2003/08/07 16:44:17 agc Exp $");
+__RCSID("$NetBSD: cuserid.c,v 1.6.6.1 2005/07/09 22:52:32 tron Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -42,21 +42,21 @@
 #include <unistd.h>
 
 char *
-cuserid(s)
-       char *s;
+cuserid(char *s)
 {
-       struct passwd *pw;
+       struct passwd *pw, pwres;
        static char buf[L_cuserid];
+       char pwbuf[1024];
 
        /* s may be NULL */
 
-       if ((pw = getpwuid(geteuid())) == NULL) {
-               if (s)
+       if (getpwuid_r(geteuid(), &pwres, pwbuf, sizeof(pwbuf), &pw) != 0) {
+               if (s != NULL)
                        *s = '\0';
-               return (s);
+               return s;
        }
-       if (!s)
+       if (s == NULL)
                s = buf;
        (void)strncpy(s, pw->pw_name, L_cuserid);
-       return (s);
+       return s;
 }



Home | Main Index | Thread Index | Old Index