From a934cfbd00a555a2667cf22203129ae6188c74be Mon Sep 17 00:00:00 2001 From: Jan Doms Date: Mon, 22 May 2017 17:55:57 +0200 Subject: [PATCH 1/2] enhance/fix invalid argument exception string payload --- src/unix/lwt_bytes.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/lwt_bytes.ml b/src/unix/lwt_bytes.ml index 082febb765..8d1de52e0a 100644 --- a/src/unix/lwt_bytes.ml +++ b/src/unix/lwt_bytes.ml @@ -60,7 +60,7 @@ 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" else unsafe_blit_from_bytes src_buf src_ofs dst_buf dst_ofs len @@ -68,7 +68,7 @@ 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" else unsafe_blit_to_bytes src_buf src_ofs dst_buf dst_ofs len @@ -76,7 +76,7 @@ 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,7 +151,7 @@ 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) @@ -159,7 +159,7 @@ external stub_send : Unix.file_descr -> t -> int -> int -> Unix.msg_flag list -> 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" From f73174b93070db3371d6627f2a2ca8e0699df7c5 Mon Sep 17 00:00:00 2001 From: Jan Doms Date: Tue, 23 May 2017 09:51:15 +0200 Subject: [PATCH 2/2] comments --- src/unix/lwt_bytes.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/lwt_bytes.ml b/src/unix/lwt_bytes.ml index 8d1de52e0a..236a4b3ac4 100644 --- a/src/unix/lwt_bytes.ml +++ b/src/unix/lwt_bytes.ml @@ -60,7 +60,7 @@ 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 "Lwt_bytes.blit" + invalid_arg "Lwt_bytes.blit_from_bytes" else unsafe_blit_from_bytes src_buf src_ofs dst_buf dst_ofs len @@ -68,7 +68,7 @@ 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 "Lwt_bytes.blit" + invalid_arg "Lwt_bytes.blit_to_bytes" else unsafe_blit_to_bytes src_buf src_ofs dst_buf dst_ofs len