aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-06-21 07:57:12 -0700
committerUlrich Drepper <drepper@redhat.com>2010-06-21 07:57:12 -0700
commite35fcef8b739ed24e083ff8a3078ac14e101cf67 (patch)
tree26a44083e73e110bf21fb65df7540d0de1e6145a /sysdeps/unix
parentac2b484c02b01307ab6bbe5d45ddbf16d64edf8c (diff)
downloadglibc-e35fcef8b739ed24e083ff8a3078ac14e101cf67.tar
glibc-e35fcef8b739ed24e083ff8a3078ac14e101cf67.tar.gz
glibc-e35fcef8b739ed24e083ff8a3078ac14e101cf67.tar.bz2
glibc-e35fcef8b739ed24e083ff8a3078ac14e101cf67.zip
More fixes to error handling in getlogin_r.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/getlogin_r.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 5c3de69e88..7d4d6c0ed5 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -27,6 +27,10 @@ static int getlogin_r_fd0 (char *name, size_t namesize);
#undef getlogin_r
+/* Try to determine login name from /proc/self/loginuid and return 0
+ if successful. If /proc/self/loginuid cannot be read return -1.
+ Otherwise return the error number. */
+
int
attribute_hidden
__getlogin_r_loginuid (name, namesize)
@@ -35,7 +39,7 @@ __getlogin_r_loginuid (name, namesize)
{
int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
- return 1;
+ return -1;
/* We are reading a 32-bit number. 12 bytes are enough for the text
representation. If not, something is wrong. */
@@ -51,7 +55,7 @@ __getlogin_r_loginuid (name, namesize)
|| (uidbuf[n] = '\0',
uid = strtoul (uidbuf, &endp, 10),
endp == uidbuf || *endp != '\0'))
- return 1;
+ return -1;
size_t buflen = 1024;
char *buf = alloca (buflen);