|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-4.6 13/13] tools/ocaml: handle strdup failure in stub_xl_device_disk_of_vdev
> On 23 Jul 2015, at 09:38, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>
> On 23/07/2015 08:59, Wei Liu wrote:
>> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
>> ---
>> Cc: dave.scott@xxxxxxxxxxxxx
>>
>> Please check if the use of caml_failwith is correct.
>
> This issue I have a different patch for, which could be 4.6 material, if
> it weren't for the same issue as identified in patch 12.
>
> In this case, Ocaml strings may contain embedded NULs which generally
> makes the use of the strxxx() functions incorrect. OTOH, the first
> thing libxl will do is assume that they are NUL terminated, so it
> probably isn't too much of a problem.
Yeah I would assume if my OCaml program sent libxl a legal OCaml string
containing NULLs, that libxl would end up truncating it at the first NULL. I
think it would be ok to document this at the OCaml level.
Cheers,
Dave
>
> There is already a dup_String_Val() function which attempts to deal with
> this, although it has failure cases from integer overflows.
>
> ~Andrew
>
>> ---
>> tools/ocaml/libs/xl/xenlight_stubs.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c
>> b/tools/ocaml/libs/xl/xenlight_stubs.c
>> index 7b8d6db..dccd7ed 100644
>> --- a/tools/ocaml/libs/xl/xenlight_stubs.c
>> +++ b/tools/ocaml/libs/xl/xenlight_stubs.c
>> @@ -780,6 +780,10 @@ value stub_xl_device_disk_of_vdev(value ctx, value
>> domid, value vdev)
>>
>> c_vdev = strdup(String_val(vdev));
>>
>> + if (!c_vdev) {
>> + caml_failwith("Failed to duplicate vdev string.");
>> + }
>> +
>> caml_enter_blocking_section();
>> libxl_vdev_to_device_disk(CTX, c_domid, c_vdev, &c_disk);
>> caml_leave_blocking_section();
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |