[libvirt] [libvirt-perl][PATCH 1/7] Fix send_all() callback helper

Michal Privoznik mprivozn at redhat.com
Tue May 23 15:05:35 UTC 2017


Sys::Virt::virStream->send_all() uses virStreamSendAll() under
the hood. This function takes one callback to fill the send
buffer with stream data. We have a C glue callback that
eventually calls the perl one. However, there's a problem with
the glue callback mangling the data as it mistakenly uses
strcpy() instead of memcpy().

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 Changes | 1 +
 Virt.xs | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Changes b/Changes
index 2e5bfe4..2e4a99e 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for perl module Sys::Virt
 3.4.0 2017-06-00
 
  - Add LIST_CAP_MDEV & LIST_CAP_MDEV_TYPES constants
+ - Fix send_all() callback helper
 
 3.3.0 2017-05-08
 
diff --git a/Virt.xs b/Virt.xs
index 9ccdc1f..a041c95 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -1948,7 +1948,7 @@ _stream_send_all_source(virStreamPtr st,
         const char *newdata = SvPV_nolen(datasv);
         if (ret > nbytes)
             ret = nbytes;
-        strncpy(data, newdata, nbytes);
+        memcpy(data, newdata, nbytes);
     }
 
     FREETMPS;
-- 
2.13.0




More information about the libvir-list mailing list