[BZ #1188]
authorUlrich Drepper <drepper@redhat.com>
Tue, 16 Aug 2005 16:05:37 +0000 (16:05 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 16 Aug 2005 16:05:37 +0000 (16:05 +0000)
2005-08-10  Sergio Gelato  <Sergio.Gelato@astro.su.se>
[BZ #1188]
* nis/nss_nis/nis-netgrp.c (_nss_nis_setnetgrent): Change assert check
from (len > 0) to (len >= 0).

2005-08-16  Ulrich Drepper  <drepper@redhat.com>

* nis/nis_xdr.c (_xdr_nis_result): Fix type of res variable.
Reported by Thomas Schwinge.

2005-08-15  Jakub Jelinek  <jakub@redhat.com>

* nis/nis_subr.c (nis_leaf_of_r): Handle buflen == 0 correctly.

2005-08-16  Ulrich Drepper  <drepper@redhat.com>

* nss/getent.c (more_help): Use open_memstream instead of handling
memory allocation ourselves.

2005-08-16  Jay Fenlason  <fenlason@redhat.com>

* nss/getent.c (parse_options): change the -s option to support
{database}:{search} to override /etc/resolv.conf for only the
specified database.

ChangeLog
nis/nis_subr.c
nis/nis_xdr.c
nis/nss_nis/nis-netgrp.c
nss/getent.c

index 51c2036..504d0fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2005-08-10  Sergio Gelato  <Sergio.Gelato@astro.su.se>
+
+       [BZ #1188]
+       * nis/nss_nis/nis-netgrp.c (_nss_nis_setnetgrent): Change assert check
+       from (len > 0) to (len >= 0).
+
+2005-08-16  Ulrich Drepper  <drepper@redhat.com>
+
+       * nis/nis_xdr.c (_xdr_nis_result): Fix type of res variable.
+       Reported by Thomas Schwinge.
+
+2005-08-15  Jakub Jelinek  <jakub@redhat.com>
+
+       * nis/nis_subr.c (nis_leaf_of_r): Handle buflen == 0 correctly.
+
+2005-08-16  Ulrich Drepper  <drepper@redhat.com>
+
+       * nss/getent.c (more_help): Use open_memstream instead of handling
+       memory allocation ourselves.
+
+2005-08-16  Jay Fenlason  <fenlason@redhat.com>
+
+       * nss/getent.c (parse_options): change the -s option to support
+       {database}:{search} to override /etc/resolv.conf for only the
+       specified database.
+
 2005-08-08  Ulrich Drepper  <drepper@redhat.com>
 
        * nscd/connections.c (main_loop_epoll): Pass NULL as event
index 5838e30..7e29168 100644 (file)
@@ -39,7 +39,7 @@ nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen)
   while (name[i] != '.' && name[i] != '\0')
     i++;
 
-  if (__builtin_expect (i > buflen - 1, 0))
+  if (__builtin_expect (i >= buflen, 0))
     {
       __set_errno (ERANGE);
       return NULL;
index 820103b..1ef08c7 100644 (file)
@@ -281,7 +281,7 @@ _xdr_nis_error (XDR *xdrs, nis_error *objp)
 bool_t
 _xdr_nis_result (XDR *xdrs, nis_result *objp)
 {
-  bool res = _xdr_nis_error (xdrs, &objp->status);
+  bool_t res = _xdr_nis_error (xdrs, &objp->status);
   if (__builtin_expect (res, TRUE))
     {
       res = xdr_array (xdrs, (char **) &objp->objects.objects_val,
index d339dd5..7bd6527 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004
+/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004,2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -75,7 +75,7 @@ _nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp)
         which is one byte larger than the value in LEN specifies
         and the last byte is filled with NUL.  So we can simply
         use that buffer.  */
-      assert (len > 0);
+      assert (len >= 0);
       assert (malloc_usable_size (netgrp->data) >= len + 1);
       assert (netgrp->data[len] == '\0');
 
index 0aea5ee..7124e63 100644 (file)
@@ -757,12 +757,27 @@ D(shadow)
 static error_t
 parse_option (int key, char *arg, struct argp_state *state)
 {
-  int i;
+  char *endp;
   switch (key)
     {
     case 's':
-      for (i = 0; databases[i].name; ++i)
-       __nss_configure_lookup (databases[i].name, arg);
+      endp = strchr (arg, ':');
+      if (endp == NULL)
+       /* No specific database, change them all.  */
+       for (int i = 0; databases[i].name != NULL; ++i)
+         __nss_configure_lookup (databases[i].name, arg);
+      else
+       {
+         int i;
+         for (i = 0; databases[i].name != NULL; ++i)
+           if (strncmp (databases[i].name, arg, endp - arg) == 0)
+             {
+               __nss_configure_lookup (databases[i].name, endp + 1);
+               break;
+             }
+         if (databases[i].name == NULL)
+           error (EXIT_FAILURE, 0, gettext ("Unknown database name"));
+       }
       break;
 
     default:
@@ -776,31 +791,20 @@ parse_option (int key, char *arg, struct argp_state *state)
 static char *
 more_help (int key, const char *text, void *input)
 {
-  int len;
-  char *long_doc, *doc, *p;
-
   switch (key)
     {
+      size_t len;
+      char *doc;
+      FILE *fp;
+
     case ARGP_KEY_HELP_EXTRA:
       /* We print some extra information.  */
-#if 0
-      return xstrdup (gettext ("\
-For bug reporting instructions, please see:\n\
-<http://www.gnu.org/software/libc/bugs.html>.\n"));
-#endif
-      long_doc = _("Supported databases:");
-      len = strlen (long_doc) + 2;
-
-      for (int i = 0; databases[i].name; ++i)
-       len += strlen (databases[i].name) + 1;
-
-      doc = (char *) malloc (len);
-      if (doc != NULL)
+      fp = open_memstream (&doc, &len);
+      if (fp != NULL)
        {
-         p = stpcpy (doc, long_doc);
-         *p++ = '\n';
+         fputs_unlocked (_("Supported databases:\n"), fp);
 
-         for (int i = 0, col = 0; databases[i].name; ++i)
+         for (int i = 0, col = 0; databases[i].name != NULL; ++i)
            {
              len = strlen (databases[i].name);
              if (i != 0)
@@ -808,17 +812,18 @@ For bug reporting instructions, please see:\n\
                  if (col + len > 72)
                    {
                      col = 0;
-                     *p++ = '\n';
+                     fputc_unlocked ('\n', fp);
                    }
                  else
-                   *p++ = ' ';
+                   fputc_unlocked (' ', fp);
                }
 
-             p = mempcpy (p, databases[i].name, len);
+             fputs_unlocked (databases[i].name, fp);
              col += len + 1;
            }
 
-         return doc;
+         if (fclose (fp) == 0)
+           return doc;
        }
       break;