Patchwork [PATCHv2,05/22] vmdk: relative_path: use pstrcpy in place of strncpy

login
register
mail settings
Submitter Jim Meyering
Date May 30, 2012, 7:46 a.m.
Message ID <1338364001-13892-6-git-send-email-jim@meyering.net>
Download mbox | patch
Permalink /patch/161916/
State New
Headers show

Comments

Jim Meyering - May 30, 2012, 7:46 a.m.
From: Jim Meyering <meyering@redhat.com>

Avoid strncpy+manual-NUL-terminate.  Use pstrcpy instead.

Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 block/vmdk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 18e9b4c..bfd7357 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1319,8 +1319,7 @@  static int relative_path(char *dest, int dest_size,
         return -1;
     }
     if (path_is_absolute(target)) {
-        dest[dest_size - 1] = '\0';
-        strncpy(dest, target, dest_size - 1);
+        pstrcpy(dest, dest_size, target);
         return 0;
     }
     while (base[i] == target[i]) {