diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2002-07-12 09:47:54 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2002-07-12 09:47:54 +0000 |
commit | ede12e6163058650508a0fbb08177ab4ee4daf02 (patch) | |
tree | 6241a927f8d50e772b0cd74ba83e5cdc0d456c5c /otherlibs/threads/unix.ml | |
parent | 4865d98f29e1f648c7b45a9304dff12604d6abb8 (diff) |
Remplacement des tests ofs + len > length par ofs > len - length, pour eviter le debordement lors de l'addition (PR#1229)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4993 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/threads/unix.ml')
-rw-r--r-- | otherlibs/threads/unix.ml | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml index c32964585..ea8a44c8f 100644 --- a/otherlibs/threads/unix.ml +++ b/otherlibs/threads/unix.ml @@ -200,7 +200,7 @@ external unsafe_write : file_descr -> string -> int -> int -> int = "unix_write" let rec read fd buf ofs len = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> @@ -208,7 +208,7 @@ let rec read fd buf ofs len = let rec write fd buf ofs len = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> @@ -604,7 +604,7 @@ external unsafe_sendto : let rec recv fd buf ofs len flags = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> @@ -612,7 +612,7 @@ let rec recv fd buf ofs len flags = let rec recvfrom fd buf ofs len flags = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> @@ -621,7 +621,7 @@ let rec recvfrom fd buf ofs len flags = let rec send fd buf ofs len flags = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> @@ -630,7 +630,7 @@ let rec send fd buf ofs len flags = let rec sendto fd buf ofs len flags addr = try - if len < 0 or 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 with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> |