Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance/fix invalid argument exception string payload #368

Merged
merged 2 commits into from
May 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/unix/lwt_bytes.ml
Original file line number Diff line number Diff line change
@@ -60,23 +60,23 @@ let blit_from_bytes src_buf src_ofs dst_buf dst_ofs len =
if (len < 0
|| src_ofs < 0 || src_ofs > Bytes.length src_buf - len
|| dst_ofs < 0 || dst_ofs > length dst_buf - len) then
invalid_arg "String.blit"
invalid_arg "Lwt_bytes.blit_from_bytes"
else
unsafe_blit_from_bytes src_buf src_ofs dst_buf dst_ofs len

let blit_to_bytes src_buf src_ofs dst_buf dst_ofs len =
if (len < 0
|| src_ofs < 0 || src_ofs > length src_buf - len
|| dst_ofs < 0 || dst_ofs > Bytes.length dst_buf - len) then
invalid_arg "String.blit"
invalid_arg "Lwt_bytes.blit_to_bytes"
else
unsafe_blit_to_bytes src_buf src_ofs dst_buf dst_ofs len

let blit src_buf src_ofs dst_buf dst_ofs len =
if (len < 0
|| src_ofs < 0 || src_ofs > length src_buf - len
|| dst_ofs < 0 || dst_ofs > length dst_buf - len) then
invalid_arg "String.blit"
invalid_arg "Lwt_bytes.blit"
else
unsafe_blit src_buf src_ofs dst_buf dst_ofs len

@@ -151,15 +151,15 @@ external stub_recv : Unix.file_descr -> t -> int -> int -> Unix.msg_flag list ->

let recv fd buf pos len flags =
if pos < 0 || len < 0 || pos > length buf - len then
invalid_arg "recv"
invalid_arg "Lwt_bytes.recv"
else
wrap_syscall Read fd (fun () -> stub_recv (unix_file_descr fd) buf pos len flags)

external stub_send : Unix.file_descr -> t -> int -> int -> Unix.msg_flag list -> int = "lwt_unix_bytes_send"

let send fd buf pos len flags =
if pos < 0 || len < 0 || pos > length buf - len then
invalid_arg "send"
invalid_arg "Lwt_bytes.send"
else
wrap_syscall Write fd (fun () -> stub_send (unix_file_descr fd) buf pos len flags)

@@ -181,7 +181,7 @@ let check_io_vectors func_name iovs =
if iov.iov_offset < 0
|| iov.iov_length < 0
|| iov.iov_offset > length iov.iov_buffer - iov.iov_length then
invalid_arg func_name)
invalid_arg ("Lwt_bytes." ^ func_name))
iovs

external stub_recv_msg : Unix.file_descr -> int -> io_vector list -> int * Unix.file_descr list = "lwt_unix_bytes_recv_msg"