[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#267546: libc6: fix getent when uid/gid starts with a digit



Package: libc6
Version: 2.3.2.ds1-13
Severity: minor
Tags: patch

Hi,
attached patch fixes a problem in getent that shows when searching for
uids/gids like:

getent passwd 1abc

where getent assumes the argument passed is a number, because it starts
with a digit. This patch has been applied to upstream CVS already.
Cheers,
 -- Guido

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: powerpc (ppc)
Kernel: Linux 2.6.8-albook12
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-7    The Berkeley database routines [gl

-- no debconf information
--- nss/getent.c.orig	2004-08-06 12:24:22.000000000 +0200
+++ nss/getent.c	2004-08-06 12:25:48.000000000 +0200
@@ -206,17 +206,14 @@
 
   for (i = 0; i < number; ++i)
     {
-      if (isdigit (key[i][0]))
-	{
+      errno = 0;
            char *ep;
            gid_t arg_gid = strtoul (key[i], &ep, 10);
 
-           if (*key[i] != '\0' && *ep == '\0')  /* valid numeric uid */
+      if (errno != EINVAL && *key[i] != '\0' && *ep == '\0')
+	/* Valid numeric gid.  */
              grp = getgrgid (arg_gid);
            else
-             grp = NULL;
-	}
-      else
 	grp = getgrnam (key[i]);
 
       if (grp == NULL)
@@ -481,17 +478,14 @@
 
   for (i = 0; i < number; ++i)
     {
-      if (isdigit (key[i][0]))
-        {
+      errno = 0;
 	   char *ep;
 	   uid_t arg_uid = strtoul (key[i], &ep, 10);
 
-           if (*key[i] != '\0' && *ep == '\0')  /* valid numeric uid */
+      if (errno != EINVAL && *key[i] != '\0' && *ep == '\0')
+	/* Valid numeric uid.  */
 	     pwd = getpwuid (arg_uid);
            else
-             pwd = NULL;
-        }
-      else
 	pwd = getpwnam (key[i]);
 
       if (pwd == NULL)

Reply to: