[PATCH 03/16] sanlock: Use virStrcpy instead of virStrncpy

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


We want a (possibly truncated) copy of the full source string so
virStrcpy is a better fit.

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

diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index aaffe30e6f..1d8f109375 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -924,9 +924,7 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,

     /* sanlock doesn't use owner_name for anything, so it's safe to take just
      * the first SANLK_NAME_LEN - 1 characters from vm_name */
-    ignore_value(virStrncpy(opt->owner_name, priv->vm_name,
-                            MIN(strlen(priv->vm_name), SANLK_NAME_LEN - 1),
-                            SANLK_NAME_LEN));
+    virStrcpy(opt->owner_name, priv->vm_name, SANLK_NAME_LEN);

     if (state && STRNEQ(state, "")) {
         if ((rv = sanlock_state_to_args((char *)state,
-- 
2.29.2




More information about the libvir-list mailing list