From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Hoes Subject: [PATCH v6 10/11] libxl: ocaml: fix memory corruption when converting string and key/values lists Date: Mon, 9 Dec 2013 15:17:29 +0000 Message-ID: <1386602250-29866-11-git-send-email-rob.hoes@citrix.com> References: <1386602250-29866-1-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1386602250-29866-1-git-send-email-rob.hoes@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Rob Hoes , ian.jackson@eu.citrix.com, dave.scott@eu.citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org Found by Coverty. CIDs: 1128562 1128563 1128564 1128565. Signed-off-by: Rob Hoes Reviewed-by: Andrew Cooper Acked-by: David Scott Acked-by: Ian Campbell --- tools/ocaml/libs/xl/xenlight_stubs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c index 2c24ea2..4fd5d07 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -160,8 +160,8 @@ static value Val_key_value_list(libxl_key_value_list *c_val) list = Val_emptylist; for (i = libxl_string_list_length((libxl_string_list *) c_val) - 1; i >= 0; i -= 2) { - val = caml_copy_string((char *) c_val[i]); - key = caml_copy_string((char *) c_val[i - 1]); + val = caml_copy_string((*c_val)[i]); + key = caml_copy_string((*c_val)[i - 1]); kv = caml_alloc_tuple(2); Store_field(kv, 0, key); Store_field(kv, 1, val); @@ -202,7 +202,7 @@ static value Val_string_list(libxl_string_list *c_val) list = Val_emptylist; for (i = libxl_string_list_length(c_val) - 1; i >= 0; i--) { - string = caml_copy_string((char *) c_val[i]); + string = caml_copy_string((*c_val)[i]); cons = caml_alloc(2, 0); Store_field(cons, 0, string); // head Store_field(cons, 1, list); // tail -- 1.7.10.4