]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* nis/nis_subr.c (nis_getnames): Add trailing dot to NIS_PATH
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Jan 2007 14:57:15 +0000 (14:57 +0000)
committerJakub Jelinek <jakub@redhat.com>
Fri, 12 Jan 2007 14:57:15 +0000 (14:57 +0000)
components which lack them.

* nis/nis_subr.c (nis_getnames): Make sure that we always return
at least one entry consisting of the parameter concatenated with
the domain.

ChangeLog
nis/nis_subr.c

index bb4739b55965bca3e6addaad26a9765492d7b296..74fbf482d56ce9240176058c13c30be43a949475 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-10-10  Ulrich Drepper  <drepper@redhat.com>
+
+       * nis/nis_subr.c (nis_getnames): Add trailing dot to NIS_PATH
+       components which lack them.
+
+       * nis/nis_subr.c (nis_getnames): Make sure that we always return
+       at least one entry consisting of the parameter concatenated with
+       the domain.
+
 2006-10-09  Jakub Jelinek  <jakub@redhat.com>
 
        * elf/dl-debug.c (_dl_debug_initialize): Check r->r_map for 0
index 40c92705012fb226b76e81a65b9e4bad5b783a3d..c68189e541b0c9a23035b69cb6fa870202fcc76b 100644 (file)
@@ -251,13 +251,16 @@ nis_getnames (const_nis_name name)
            {
              char *p;
 
-             tmp = malloc (cplen + name_len + 2);
+             tmp = malloc (cplen + name_len + 3);
              if (__builtin_expect (tmp == NULL, 0))
                goto free_null;
 
-             p = __stpcpy (tmp, name);
+             p = __mempcpy (tmp, name, name_len);
              *p++ = '.';
-             memcpy (p, cp, cplen + 1);
+             p = __mempcpy (p, cp, cplen);
+             if (p[-1] != '.')
+               *p++ = '.';
+             *p = '\0';
            }
 
          if (pos >= count)
@@ -275,6 +278,13 @@ nis_getnames (const_nis_name name)
       cp = __strtok_r (NULL, ":", &saveptr);
     }
 
+  if (pos == 0
+      && __asprintf (&getnames[pos++], "%s%s%s%s",
+                    name, name[name_len - 1] == '.' ? "" : ".",
+                    local_domain,
+                    local_domain[local_domain_len - 1] == '.' ? "" : ".") < 0)
+    goto free_null;
+
   getnames[pos] = NULL;
 
   return getnames;