diff options
author | Richard Jones <rjones@redhat.com> | 2010-06-16 15:25:45 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-06-16 15:32:20 +0100 |
commit | 1079f74704a06c06996e547fdecf20a8f92799c6 (patch) | |
tree | 32b272a9b86952f06f8565526c1fe5d8cf09bee7 /ocaml/guestfs_c.h | |
parent | 1e568f057e8bb7b36cc14e0e531d74b75ad9cb6c (diff) | |
download | libguestfs-1079f74704a06c06996e547fdecf20a8f92799c6.tar.gz libguestfs-1079f74704a06c06996e547fdecf20a8f92799c6.tar.xz libguestfs-1079f74704a06c06996e547fdecf20a8f92799c6.zip |
ocaml: Fix thread safety of strings in bindings (RHBZ#604691).
There's a thread safety issue with the current OCaml bindings which
is well explained in the bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=604691
This commit fixes the safety issue by copying strings temporarily
before releasing the thread lock. Updated code looks like this:
char *filename = guestfs_safe_strdup (g, String_val (filenamev));
int r;
caml_enter_blocking_section ();
r = guestfs_add_drive_ro (g, filename);
caml_leave_blocking_section ();
free (filename);
if (r == -1)
ocaml_guestfs_raise_error (g, "add_drive_ro");
Also included is a regression test.
Diffstat (limited to 'ocaml/guestfs_c.h')
-rw-r--r-- | ocaml/guestfs_c.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ocaml/guestfs_c.h b/ocaml/guestfs_c.h index cd1d73b1..29da0532 100644 --- a/ocaml/guestfs_c.h +++ b/ocaml/guestfs_c.h @@ -19,6 +19,8 @@ #ifndef GUESTFS_OCAML_C_H #define GUESTFS_OCAML_C_H +#include "guestfs-internal.h" + #define Guestfs_val(v) (*((guestfs_h **)Data_custom_val(v))) extern void ocaml_guestfs_raise_error (guestfs_h *g, const char *func) Noreturn; |