Skip to content

Commit

Permalink
tools/ocaml: libxb: Harden stub_header_of_string()
Browse files Browse the repository at this point in the history
stub_header_of_string() should not modify the header. So mark the
variable 'hdr' as const.

Signed-off-by: Julien Grall <[email protected]>
Acked-by: Christian Lindig <[email protected]>
  • Loading branch information
Julien Grall committed Apr 20, 2020
1 parent 3bf6969 commit d92ba1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/ocaml/libs/xb/xenbus_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d92ba1a

Please sign in to comment.