This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, release/2.12/master, updated. glibc-2.12.1-3-gd8d583f


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.12/master has been updated
       via  d8d583fc44fbdc7014ae1f684589afd8214e73be (commit)
       via  d48b760747e6e6eac5d294667a2aac94f55b7649 (commit)
       via  5305f9b09df3450b69d45bcf84d45afa6d9fd577 (commit)
      from  6164128f1ca84eea240b66f977054e16b94b3c86 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d8d583fc44fbdc7014ae1f684589afd8214e73be

commit d8d583fc44fbdc7014ae1f684589afd8214e73be
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Tue Aug 17 11:05:30 2010 +0200

    (__getlogin_r_loginuid): Also fail if tpwd after pwuid call is NULL.
    (cherry picked from commit c86434ccb576a3ce35b5a74f72b9f03bd45b522a)

diff --git a/ChangeLog b/ChangeLog
index 42efab9..31c6a64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-06  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
+	Also fail if tpwd after pwuid call is NULL.
+
 2010-06-21  Andreas Schwab <schwab@redhat.com>
 
 	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 7d4d6c0..42041ee 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -81,7 +81,7 @@ __getlogin_r_loginuid (name, namesize)
 	use_malloc = true;
       }
 
-  if (res != 0)
+  if (res != 0 || tpwd == NULL)
     {
       result = -1;
       goto out;

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d48b760747e6e6eac5d294667a2aac94f55b7649

commit d48b760747e6e6eac5d294667a2aac94f55b7649
Author: Andreas Schwab <schwab@redhat.com>
Date:   Mon Jun 21 07:57:12 2010 -0700

    More fixes to error handling in getlogin_r.
    (cherry picked from commit e35fcef8b739ed24e083ff8a3078ac14e101cf67)

diff --git a/ChangeLog b/ChangeLog
index 1573eb3..42efab9 100644
--- a/ChangeLog
+++ b/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>
 
 	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 5c3de69..7d4d6c0 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);

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=5305f9b09df3450b69d45bcf84d45afa6d9fd577

commit 5305f9b09df3450b69d45bcf84d45afa6d9fd577
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Sat Jun 19 09:54:28 2010 -0700

    Fix error handling in Linux getlogin*.
    (cherry picked from commit 63c4ed22b5048c8701d8806026c23cc95f0df756)

diff --git a/ChangeLog b/ChangeLog
index b9dd2f0..1573eb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-06-19  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
+	OOM in getpwuid_r correctly.  Return error number when the caller
+	should return, otherwise -1.
+	(getlogin_r): Adjust to return also for result of __getlogin_r_loginuid
+	call returning > 0 value.
+	* sysdeps/unix/sysv/linux/getlogin.c (getlogin): Likewise.
+
 2010-07-27  Andreas Schwab  <schwab@redhat.com>
 
 	* version.h (VERSION): Bump for 2.12.1 release.
diff --git a/sysdeps/unix/sysv/linux/getlogin.c b/sysdeps/unix/sysv/linux/getlogin.c
index 4d15db0..58e37c4 100644
--- a/sysdeps/unix/sysv/linux/getlogin.c
+++ b/sysdeps/unix/sysv/linux/getlogin.c
@@ -32,8 +32,9 @@
 char *
 getlogin (void)
 {
-  if (__getlogin_r_loginuid (name, sizeof (name)) == 0)
-    return name;
+  int res = __getlogin_r_loginuid (name, sizeof (name));
+  if (res >= 0)
+    return res == 0 ? name : NULL;
 
   return getlogin_fd0 ();
 }
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index dad2671..5c3de69 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -58,30 +58,31 @@ __getlogin_r_loginuid (name, namesize)
   bool use_malloc = false;
   struct passwd pwd;
   struct passwd *tpwd;
+  int result = 0;
   int res;
 
-  while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) != 0)
+  while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) == ERANGE)
     if (__libc_use_alloca (2 * buflen))
-      extend_alloca (buf, buflen, 2 * buflen);
+      buf = extend_alloca (buf, buflen, 2 * buflen);
     else
       {
 	buflen *= 2;
 	char *newp = realloc (use_malloc ? buf : NULL, buflen);
 	if (newp == NULL)
 	  {
-	  fail:
-	    if (use_malloc)
-	      free (buf);
-	    return 1;
+	    result = ENOMEM;
+	    goto out;
 	  }
 	buf = newp;
 	use_malloc = true;
       }
 
-  if (tpwd == NULL)
-    goto fail;
+  if (res != 0)
+    {
+      result = -1;
+      goto out;
+    }
 
-  int result = 0;
   size_t needed = strlen (pwd.pw_name) + 1;
   if (needed > namesize)
     {
@@ -109,8 +110,9 @@ getlogin_r (name, namesize)
      char *name;
      size_t namesize;
 {
-  if (__getlogin_r_loginuid (name, namesize) == 0)
-    return 0;
+  int res = __getlogin_r_loginuid (name, namesize);
+  if (res >= 0)
+    return res;
 
   return getlogin_r_fd0 (name, namesize);
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                            |   19 +++++++++++++++++++
 sysdeps/unix/sysv/linux/getlogin.c   |    5 +++--
 sysdeps/unix/sysv/linux/getlogin_r.c |   32 +++++++++++++++++++-------------
 3 files changed, 41 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]