open Stdext
+let xenstore_payload_max = 4096 (* xen/include/public/io/xs_wire.h *)
+
type watch = {
con: t;
token: string;
let set_target con target_domid =
con.perm <- Perms.Connection.set_target (get_perm con) ~perms:[Perms.READ; Perms.WRITE] target_domid
+let is_backend_mmap con = match con.xb.Xenbus.Xb.backend with
+ | Xenbus.Xb.Xenmmap _ -> true
+ | _ -> false
+
let send_reply con tid rid ty data =
- Xb.queue con.xb (Xb.Packet.create tid rid ty data)
+ if (String.length data) > xenstore_payload_max && (is_backend_mmap con) then
+ Xb.queue con.xb (Xb.Packet.create tid rid Xb.Op.Error "E2BIG\000")
+ else
+ Xb.queue con.xb (Xb.Packet.create tid rid ty data)
let send_error con tid rid err = send_reply con tid rid Xb.Op.Error (err ^ "\000")
let send_ack con tid rid ty = send_reply con tid rid ty "OK\000"
{
struct buffered_data *bdata;
+ if ( len > XENSTORE_PAYLOAD_MAX ) {
+ send_error(conn, E2BIG);
+ return;
+ }
+
/* Message is a child of the connection context for auto-cleanup. */
bdata = new_buffer(conn);
bdata->buffer = talloc_array(bdata, char, len);