From: Julien Grall Date: Mon, 30 Mar 2020 13:29:10 +0000 (+0100) Subject: tools/ocaml: libxb: Harden stub_header_of_string() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=939164f40a9d060e086554e2d6d36346b9be7637;p=xen.git 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 Acked-by: Christian Lindig (cherry picked from commit d92ba1aa7cf877a77abdcbd94a6a19fc55886a75) --- 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));