btrfs-progs: use strncpy in is_same_blk_file
authorDavid Sterba <dsterba@suse.cz>
Sat, 3 Jan 2015 02:10:55 +0000 (03:10 +0100)
committerDavid Sterba <dsterba@suse.cz>
Sat, 3 Jan 2015 02:22:19 +0000 (03:22 +0100)
Although we're getting strings from the caller, let's be safe.

Resolves-coverity-id: 1199475
Signed-off-by: David Sterba <dsterba@suse.cz>
utils.c

diff --git a/utils.c b/utils.c
index af0a8fe..531bc82 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -1005,11 +1005,11 @@ static int is_same_blk_file(const char* a, const char* b)
        char real_a[PATH_MAX];
        char real_b[PATH_MAX];
 
-       if(!realpath(a, real_a))
-               strcpy(real_a, a);
+       if (!realpath(a, real_a))
+               strncpy_null(real_a, a);
 
        if (!realpath(b, real_b))
-               strcpy(real_b, b);
+               strncpy_null(real_b, b);
 
        /* Identical path? */
        if(strcmp(real_a, real_b) == 0)