summary refs log tree commit diff
path: root/nis/nis_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nis_subr.c')
-rw-r--r--nis/nis_subr.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/nis/nis_subr.c b/nis/nis_subr.c
index 93e34f13cb..c68189e541 100644
--- a/nis/nis_subr.c
+++ b/nis/nis_subr.c
@@ -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)