summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix/unix.ml
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix/unix.ml')
-rw-r--r--otherlibs/unix/unix.ml12
1 files changed, 6 insertions, 6 deletions
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index 4ec83890a..daa24e61e 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -163,11 +163,11 @@ external unsafe_read : file_descr -> string -> int -> int -> int = "unix_read"
external unsafe_write : file_descr -> string -> int -> int -> int = "unix_write"
let read fd buf ofs len =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.read"
else unsafe_read fd buf ofs len
let write fd buf ofs len =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.write"
else unsafe_write fd buf ofs len
@@ -456,19 +456,19 @@ external unsafe_sendto :
= "unix_sendto" "unix_sendto_native"
let recv fd buf ofs len flags =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.recv"
else unsafe_recv fd buf ofs len flags
let recvfrom fd buf ofs len flags =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.recvfrom"
else unsafe_recvfrom fd buf ofs len flags
let send fd buf ofs len flags =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.send"
else unsafe_send fd buf ofs len flags
let sendto fd buf ofs len flags addr =
- if len < 0 || ofs + len > String.length buf
+ if ofs < 0 || len < 0 || ofs > String.length buf - len
then invalid_arg "Unix.sendto"
else unsafe_sendto fd buf ofs len flags addr