]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_subr.c
Add script to update copyright notices and reformat some to facilitate its use.
[thirdparty/glibc.git] / nis / nis_subr.c
index 93e34f13cbe1123268e72e193fecfcf54d5a5b41..44c95f4fca3183aecf38419cfc7bd27a02b0333e 100644 (file)
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <string.h>
@@ -112,7 +111,7 @@ nis_getnames (const_nis_name name)
   size_t name_len = strlen (name);
   char *path;
   int pos = 0;
-  char *saveptr;
+  char *saveptr = NULL;
   int have_point;
   const char *cp;
   const char *cp2;
@@ -251,13 +250,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)