Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > bee470e21a8ce2cdd844d7d805aa403d > files > 138

glibc-2.5-49.el5_5.6.src.rpm

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.

--- libc/nis/nis_subr.c	16 Jun 2006 22:30:02 -0000	1.15
+++ libc/nis/nis_subr.c	11 Oct 2006 01:27:38 -0000	1.17
@@ -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;