[libvirt] [PATCH v2 7/8] esx: Use memcpy() in esxVI_CURL_Debug()

Andrea Bolognani abologna at redhat.com
Fri Jul 20 14:44:12 UTC 2018


We're going to change virStrncpy() in a way that
requires the source string to be NULL-terminated, so
we'll no longer be able to use in this context.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/esx/esx_vi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 727d76e89d..a816c3a4f9 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -185,10 +185,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
     if (VIR_ALLOC_N(buffer, size + 1) < 0)
         return 0;
 
-    if (virStrncpy(buffer, info, size, size + 1) < 0) {
-        VIR_FREE(buffer);
-        return 0;
-    }
+    memcpy(buffer, info, size);
+    buffer[size] = '\0';
 
     switch (type) {
       case CURLINFO_TEXT:
-- 
2.17.1




More information about the libvir-list mailing list