[libvirt] [PATCH] Convert one use of strncpy + strcat to snprintf in test driver.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 src/test.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/test.c b/src/test.c
index 470816b..ab6cfdf 100644
--- a/src/test.c
+++ b/src/test.c
@@ -417,9 +417,8 @@ static char *testBuildFilename(const char *relativeTo,
         char *absFile;
         if (VIR_ALLOC_N(absFile, baseLen + strlen(filename) + 1) < 0)
             return NULL;
-        strncpy(absFile, relativeTo, baseLen);
-        absFile[baseLen] = '\0';
-        strcat(absFile, filename);
+        snprintf(absFile, baseLen + strlen(filename) + 1, "%s%s",
+                 relativeTo, filename);
         return absFile;
     } else {
         return strdup(filename);
-- 
1.6.0.6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]