]> xenbits.xensource.com Git - xen.git/commitdiff
tools/ocaml: libxb: Harden stub_header_of_string()
authorJulien Grall <jgrall@amazon.com>
Mon, 30 Mar 2020 13:29:10 +0000 (14:29 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 19 Mar 2021 13:46:25 +0000 (13:46 +0000)
stub_header_of_string() should not modify the header. So mark the
variable 'hdr' as const.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
(cherry picked from commit d92ba1aa7cf877a77abdcbd94a6a19fc55886a75)

tools/ocaml/libs/xb/xenbus_stubs.c

index a68e783f708b4395acd9ad7764599edcbaa63dc4..001bb033710943dab6022e71e34ad3311fa7c239 100644 (file)
@@ -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));