projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
[gnulib.git]
/
lib
/
getlogin_r.c
diff --git
a/lib/getlogin_r.c
b/lib/getlogin_r.c
index
c02db2f
..
371164a
100644
(file)
--- a/
lib/getlogin_r.c
+++ b/
lib/getlogin_r.c
@@
-18,7
+18,7
@@
/* written by Paul Eggert and Derek Price */
/* written by Paul Eggert and Derek Price */
-#if HAVE_CONFIG_H
+#if
def
HAVE_CONFIG_H
# include <config.h>
#endif
# include <config.h>
#endif
@@
-26,10
+26,7
@@
#include <errno.h>
#include <string.h>
#include <errno.h>
#include <string.h>
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
#if !HAVE_DECL_GETLOGIN
char *getlogin (void);
#if !HAVE_DECL_GETLOGIN
char *getlogin (void);
@@
-44,8
+41,15
@@
getlogin_r (char *name, size_t size)
errno = 0;
n = getlogin ();
errno = 0;
n = getlogin ();
+
+ /* A system function like getlogin_r is never supposed to set errno
+ to zero, so make sure errno is nonzero here. ENOENT is a
+ reasonable errno value if getlogin returns NULL. */
+ if (!errno)
+ errno = ENOENT;
+
if (!n)
if (!n)
- return errno
? errno : ENOENT
;
+ return errno;
nlen = strlen (n);
if (size <= nlen)
return ERANGE;
nlen = strlen (n);
if (size <= nlen)
return ERANGE;