Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More fixes to error handling in getlogin_r.
  • Loading branch information
Andreas Schwab authored and Ulrich Drepper committed Jun 21, 2010
1 parent ac2b484 commit e35fcef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2010-06-21 Andreas Schwab <schwab@redhat.com>

* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Restore proper fallback handling.

2010-06-19 Ulrich Drepper <drepper@redhat.com>

[BZ #11701]
Expand Down
8 changes: 6 additions & 2 deletions sysdeps/unix/sysv/linux/getlogin_r.c
Expand Up @@ -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)
Expand All @@ -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. */
Expand All @@ -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);
Expand Down

0 comments on commit e35fcef

Please sign in to comment.