[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] tools/ocaml: libxb: Harden stub_header_of_string()



commit d92ba1aa7cf877a77abdcbd94a6a19fc55886a75
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Mon Mar 30 14:29:10 2020 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Mon Apr 20 15:03:03 2020 +0100

    tools/ocaml: libxb: Harden stub_header_of_string()
    
    stub_header_of_string() should not modify the header. So mark the
    variable 'hdr' as const.
    
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
---
 tools/ocaml/libs/xb/xenbus_stubs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/libs/xb/xenbus_stubs.c 
b/tools/ocaml/libs/xb/xenbus_stubs.c
index a68e783f70..001bb03371 100644
--- a/tools/ocaml/libs/xb/xenbus_stubs.c
+++ b/tools/ocaml/libs/xb/xenbus_stubs.c
@@ -40,12 +40,12 @@ CAMLprim value stub_header_of_string(value s)
 {
        CAMLparam1(s);
        CAMLlocal1(ret);
-       struct xsd_sockmsg *hdr;
+       const struct xsd_sockmsg *hdr;
 
        if (caml_string_length(s) != sizeof(struct xsd_sockmsg))
                caml_failwith("xb header incomplete");
        ret = caml_alloc_tuple(4);
-       hdr = (struct xsd_sockmsg *) String_val(s);
+       hdr = (const struct xsd_sockmsg *) String_val(s);
        Store_field(ret, 0, Val_int(hdr->tx_id));
        Store_field(ret, 1, Val_int(hdr->req_id));
        Store_field(ret, 2, Val_int(hdr->type));
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.