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

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



Signed-off-by: Chris Lalancette <clalance redhat com>
---
 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


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