about summary refs log tree commit diff
path: root/hesiod
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-20 06:33:30 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-20 06:33:30 +0000
commit521a2f6584a8deb317f42dbe780a1c373b6e4e6a (patch)
tree2b563261dc4edea0553d06d2ea7e49b76c859930 /hesiod
parentaab0963999b40fac0b8df76a889097e8bd703e1f (diff)
downloadglibc-521a2f6584a8deb317f42dbe780a1c373b6e4e6a.tar.gz
glibc-521a2f6584a8deb317f42dbe780a1c373b6e4e6a.tar.xz
glibc-521a2f6584a8deb317f42dbe780a1c373b6e4e6a.zip
(_nss_hesiod_initgroups_dyn): Correctly handle numeric group member information. Complete test for strtol overflow.
Diffstat (limited to 'hesiod')
-rw-r--r--hesiod/nss_hesiod/hesiod-grp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
index 5551d7d012..cb7c0870e2 100644
--- a/hesiod/nss_hesiod/hesiod-grp.c
+++ b/hesiod/nss_hesiod/hesiod-grp.c
@@ -174,6 +174,7 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
   char *p;
   void *context;
   gid_t *groups = *groupsp;
+  int save_errno;
 
   context = _nss_hesiod_init ();
   if (context == NULL)
@@ -214,6 +215,8 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
       groups[(*start)++] = group;
     }
 
+  save_errno = errno;
+
   p = *list;
   while (*p != '\0')
     {
@@ -224,17 +227,24 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
       status = NSS_STATUS_NOTFOUND;
 
       q = p;
-      while (*q != '\0' && *q != ':')
+      while (*q != '\0' && *q != ':' && *q != ',')
 	++q;
 
       if (*q != '\0')
 	*q++ = '\0';
 
+      __set_errno (0);
       val = strtol (p, &endp, 10);
-      if (sizeof (gid_t) == sizeof (long int) || (gid_t) val == val)
+      /* Test whether the number is representable in a variable of
+         type `gid_t'.  If not ignore the number.  */
+      if ((sizeof (gid_t) == sizeof (long int) || (gid_t) val == val)
+	  && errno == 0)
 	{
 	  if (*endp == '\0' && endp != p)
-	    status = NSS_STATUS_SUCCESS;
+	    {
+	      group = val;
+	      status = NSS_STATUS_SUCCESS;
+	    }
 	  else
 	    status = internal_gid_from_group (context, p, &group);
 
@@ -270,6 +280,8 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
       p = q;
     }
 
+  __set_errno (save_errno);
+
  done:
   hesiod_free_list (context, list);
   hesiod_end (context);