From bb3b912b0a43b8b740a05ad1d15686e68f8e3f39 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 5 May 2012 11:30:01 +0200 Subject: [PATCH] maint: s/strncpy/memcpy/, when equivalent * src/output.c (output_skeleton): Use memcpy, not strncpy, since the source is known to fit in the destination buffer. * src/parse-gram.y (%skeleton): Likewise. --- src/output.c | 2 +- src/parse-gram.y | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index c481e14e..e0d6ed3a 100644 --- a/src/output.c +++ b/src/output.c @@ -512,7 +512,7 @@ output_skeleton (void) full_skeleton = xmalloc (pkgdatadirlen + 1 + (skeleton_size < sizeof m4sugar ? sizeof m4sugar : skeleton_size)); - strncpy (full_skeleton, pkgdatadir, pkgdatadirlen); + memcpy (full_skeleton, pkgdatadir, pkgdatadirlen); full_skeleton[pkgdatadirlen] = '/'; strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar); full_m4sugar = xstrdup (full_skeleton); diff --git a/src/parse-gram.y b/src/parse-gram.y index 33b802ed..1968e310 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -322,7 +322,7 @@ prologue_declaration: xmalloc (dir_length + 1 + strlen (skeleton_user) + 1); if (dir_length > 0) { - strncpy (skeleton_build, current_file, dir_length); + memcpy (skeleton_build, current_file, dir_length); skeleton_build[dir_length++] = '/'; } strcpy (skeleton_build + dir_length, skeleton_user); -- 2.45.2