Blame SOURCES/0003-Don-t-try-to-memcpy-into-a-String_val.patch

5be1a8
From 3d3d6af425d369200a7a62a127adf640d94a38a3 Mon Sep 17 00:00:00 2001
5be1a8
From: "Richard W.M. Jones" <rjones@redhat.com>
5be1a8
Date: Sun, 19 Jan 2020 13:02:16 +0000
5be1a8
Subject: [PATCH 3/3] Don't try to memcpy into a String_val.
5be1a8
5be1a8
In OCaml 4.10 String_val returns const char *, so we cannot use it as
5be1a8
the destination for memcpy.  Use Bytes_val instead.
5be1a8
---
5be1a8
 libvirt/generator.pl        | 2 +-
5be1a8
 libvirt/libvirt_c_oneoffs.c | 8 ++++----
5be1a8
 2 files changed, 5 insertions(+), 5 deletions(-)
5be1a8
5be1a8
diff --git a/libvirt/generator.pl b/libvirt/generator.pl
5be1a8
index aff371b..463a19b 100755
5be1a8
--- a/libvirt/generator.pl
5be1a8
+++ b/libvirt/generator.pl
5be1a8
@@ -440,7 +440,7 @@ sub gen_c_code
5be1a8
 
5be1a8
   /* UUIDs are byte arrays with a fixed length. */
5be1a8
   rv = caml_alloc_string (VIR_UUID_BUFLEN);
5be1a8
-  memcpy (String_val (rv), uuid, VIR_UUID_BUFLEN);
5be1a8
+  memcpy (Bytes_val (rv), uuid, VIR_UUID_BUFLEN);
5be1a8
   CAMLreturn (rv);
5be1a8
 "
5be1a8
     } elsif ($sig =~ /^(\w+) : uuid string$/) {
5be1a8
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
5be1a8
index fc2ac13..e8472b7 100644
5be1a8
--- a/libvirt/libvirt_c_oneoffs.c
5be1a8
+++ b/libvirt/libvirt_c_oneoffs.c
5be1a8
@@ -394,7 +394,7 @@ ocaml_libvirt_connect_call_auth_default_callback (value listv)
5be1a8
       elemv = caml_alloc (2, 0);
5be1a8
       if (cred->result != NULL && cred->resultlen > 0) {
5be1a8
         v = caml_alloc_string (cred->resultlen);
5be1a8
-        memcpy (String_val (v), cred->result, cred->resultlen);
5be1a8
+        memcpy (Bytes_val (v), cred->result, cred->resultlen);
5be1a8
         optv = caml_alloc (1, 0);
5be1a8
         Store_field (optv, 0, v);
5be1a8
       } else
5be1a8
@@ -715,7 +715,7 @@ ocaml_libvirt_domain_get_vcpus (value domv, value maxinfov, value maplenv)
5be1a8
 
5be1a8
   /* Copy the bitmap. */
5be1a8
   strv = caml_alloc_string (maxinfo * maplen);
5be1a8
-  memcpy (String_val (strv), cpumaps, maxinfo * maplen);
5be1a8
+  memcpy (Bytes_val (strv), cpumaps, maxinfo * maplen);
5be1a8
 
5be1a8
   /* Allocate the tuple and return it. */
5be1a8
   rv = caml_alloc_tuple (3);
5be1a8
@@ -900,7 +900,7 @@ ocaml_libvirt_domain_get_all_domain_stats (value connv,
5be1a8
      */
5be1a8
     v = caml_alloc_string (VIR_UUID_BUFLEN);
5be1a8
     virDomainGetUUID (rstats[i]->dom, uuid);
5be1a8
-    memcpy (String_val (v), uuid, VIR_UUID_BUFLEN);
5be1a8
+    memcpy (Bytes_val (v), uuid, VIR_UUID_BUFLEN);
5be1a8
     Store_field (dsv, 0, v);
5be1a8
 
5be1a8
     tpv = caml_alloc (rstats[i]->nparams, 0); /* typed_param array */
5be1a8
@@ -1646,7 +1646,7 @@ ocaml_libvirt_secret_get_value (value secv)
5be1a8
   CHECK_ERROR (secval == NULL, "virSecretGetValue");
5be1a8
 
5be1a8
   rv = caml_alloc_string (size);
5be1a8
-  memcpy (String_val (rv), secval, size);
5be1a8
+  memcpy (Bytes_val (rv), secval, size);
5be1a8
   free (secval);
5be1a8
 
5be1a8
   CAMLreturn (rv);
5be1a8
-- 
5be1a8
2.24.1
5be1a8