[PATCH 05/16] virFileLoopDeviceAssociate: Use virStrcpy instead of virStrncpy

Peter Krempa pkrempa at redhat.com
Tue Mar 2 14:49:22 UTC 2021


Passing 'strlen(src)' for length makes it equivalent to virStrcpy.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virfile.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 841a0f4e00..29445fc0ff 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -810,8 +810,7 @@ int virFileLoopDeviceAssociate(const char *file,
     lo.lo_flags = LO_FLAGS_AUTOCLEAR;

     /* Set backing file name for LOOP_GET_STATUS64 queries */
-    if (virStrncpy((char *) lo.lo_file_name, file,
-                   strlen(file), LO_NAME_SIZE) < 0) {
+    if (virStrcpy((char *) lo.lo_file_name, file, LO_NAME_SIZE) < 0) {
         virReportSystemError(errno,
                              _("Unable to set backing file %s"), file);
         goto cleanup;
-- 
2.29.2




More information about the libvir-list mailing list