summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot/ocamlcbin850764 -> 854958 bytes
-rwxr-xr-xboot/ocamllexbin94751 -> 97356 bytes
-rw-r--r--otherlibs/threads/marshal.ml6
-rw-r--r--otherlibs/threads/pervasives.ml6
-rw-r--r--otherlibs/threads/unix.ml12
-rw-r--r--otherlibs/unix/unix.ml12
-rw-r--r--otherlibs/win32unix/unix.ml12
-rw-r--r--stdlib/array.ml8
-rw-r--r--stdlib/buffer.ml2
-rw-r--r--stdlib/digest.ml2
-rw-r--r--stdlib/marshal.ml8
-rw-r--r--stdlib/pervasives.ml8
-rw-r--r--stdlib/string.ml8
13 files changed, 42 insertions, 42 deletions
diff --git a/boot/ocamlc b/boot/ocamlc
index 171175409..4caea59dd 100755
--- a/boot/ocamlc
+++ b/boot/ocamlc
Binary files differ
diff --git a/boot/ocamllex b/boot/ocamllex
index 3035c8a33..d1aa933f0 100755
--- a/boot/ocamllex
+++ b/boot/ocamllex
Binary files differ
diff --git a/otherlibs/threads/marshal.ml b/otherlibs/threads/marshal.ml
index 3b3a4cfa2..7be4d04dd 100644
--- a/otherlibs/threads/marshal.ml
+++ b/otherlibs/threads/marshal.ml
@@ -39,17 +39,17 @@ external data_size_unsafe: string -> int -> int = "marshal_data_size"
let header_size = 20
let data_size buff ofs =
- if ofs < 0 || ofs + header_size > String.length buff
+ if ofs < 0 || ofs > String.length buff - header_size
then invalid_arg "Marshal.data_size"
else data_size_unsafe buff ofs
let total_size buff ofs = header_size + data_size buff ofs
let from_string buff ofs =
- if ofs < 0 || ofs + header_size > String.length buff
+ if ofs < 0 || ofs > String.length buff - header_size
then invalid_arg "Marshal.from_size"
else begin
let len = data_size_unsafe buff ofs in
- if ofs + header_size + len > String.length buff
+ if ofs > String.length buff - (header_size + len)
then invalid_arg "Marshal.from_string"
else from_string_unsafe buff ofs
end
diff --git a/otherlibs/threads/pervasives.ml b/otherlibs/threads/pervasives.ml
index 2e342dfb0..80c06b120 100644
--- a/otherlibs/threads/pervasives.ml
+++ b/otherlibs/threads/pervasives.ml
@@ -308,7 +308,7 @@ let output_string oc s =
unsafe_output oc s 0 (string_length s)
let output oc s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "output"
else unsafe_output oc s ofs len
@@ -373,7 +373,7 @@ let rec unsafe_input ic s ofs len =
wait_inchan ic; unsafe_input ic s ofs len
let input ic s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "input"
else unsafe_input ic s ofs len
@@ -388,7 +388,7 @@ let rec unsafe_really_input ic s ofs len =
end
let really_input ic s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "really_input"
else unsafe_really_input ic s ofs len
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), _, _) ->
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
diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml
index 5231507e1..5bec474e2 100644
--- a/otherlibs/win32unix/unix.ml
+++ b/otherlibs/win32unix/unix.ml
@@ -184,11 +184,11 @@ 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
@@ -549,19 +549,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
diff --git a/stdlib/array.ml b/stdlib/array.ml
index 175a3516f..20d949675 100644
--- a/stdlib/array.ml
+++ b/stdlib/array.ml
@@ -85,7 +85,7 @@ let concat al =
in find_init al
let sub a ofs len =
- if ofs < 0 || len < 0 || ofs + len > length a then invalid_arg "Array.sub"
+ if ofs < 0 || len < 0 || ofs > length a - len then invalid_arg "Array.sub"
else if len = 0 then [||]
else begin
let r = create len (unsafe_get a ofs) in
@@ -94,13 +94,13 @@ let sub a ofs len =
end
let fill a ofs len v =
- if ofs < 0 || len < 0 || ofs + len > length a
+ if ofs < 0 || len < 0 || ofs > length a - len
then invalid_arg "Array.fill"
else for i = ofs to ofs + len - 1 do unsafe_set a i v done
let blit a1 ofs1 a2 ofs2 len =
- if len < 0 || ofs1 < 0 || ofs1 + len > length a1
- || ofs2 < 0 || ofs2 + len > length a2
+ if len < 0 || ofs1 < 0 || ofs1 > length a1 - len
+ || ofs2 < 0 || ofs2 > length a2 - len
then invalid_arg "Array.blit"
else if ofs1 < ofs2 then
(* Top-down copy *)
diff --git a/stdlib/buffer.ml b/stdlib/buffer.ml
index 855c81d61..e31b7b80a 100644
--- a/stdlib/buffer.ml
+++ b/stdlib/buffer.ml
@@ -56,7 +56,7 @@ let add_char b c =
b.position <- pos + 1
let add_substring b s offset len =
- if offset < 0 || len < 0 || offset + len > String.length s
+ if offset < 0 || len < 0 || offset > String.length s - len
then invalid_arg "Buffer.add_substring";
let new_position = b.position + len in
if new_position > b.length then resize b len;
diff --git a/stdlib/digest.ml b/stdlib/digest.ml
index 29d1295c7..04603303b 100644
--- a/stdlib/digest.ml
+++ b/stdlib/digest.ml
@@ -24,7 +24,7 @@ let string str =
unsafe_string str 0 (String.length str)
let substring str ofs len =
- if ofs < 0 || len < 0 || ofs + len > String.length str
+ if ofs < 0 || len < 0 || ofs > String.length str - len
then invalid_arg "Digest.substring"
else unsafe_string str ofs len
diff --git a/stdlib/marshal.ml b/stdlib/marshal.ml
index e248c468d..ffe397dec 100644
--- a/stdlib/marshal.ml
+++ b/stdlib/marshal.ml
@@ -26,7 +26,7 @@ external to_buffer_unsafe:
= "output_value_to_buffer"
let to_buffer buff ofs len v flags =
- if ofs < 0 || len < 0 || ofs + len > String.length buff
+ if ofs < 0 || len < 0 || ofs > String.length buff - len
then invalid_arg "Marshal.to_buffer: substring out of bounds"
else to_buffer_unsafe buff ofs len v flags
@@ -36,17 +36,17 @@ external data_size_unsafe: string -> int -> int = "marshal_data_size"
let header_size = 20
let data_size buff ofs =
- if ofs < 0 || ofs + header_size > String.length buff
+ if ofs < 0 || ofs > String.length buff - header_size
then invalid_arg "Marshal.data_size"
else data_size_unsafe buff ofs
let total_size buff ofs = header_size + data_size buff ofs
let from_string buff ofs =
- if ofs < 0 || ofs + header_size > String.length buff
+ if ofs < 0 || ofs > String.length buff - header_size
then invalid_arg "Marshal.from_size"
else begin
let len = data_size_unsafe buff ofs in
- if ofs + header_size + len > String.length buff
+ if ofs > String.length buff - (header_size + len)
then invalid_arg "Marshal.from_string"
else from_string_unsafe buff ofs
end
diff --git a/stdlib/pervasives.ml b/stdlib/pervasives.ml
index b048ef33a..66822723a 100644
--- a/stdlib/pervasives.ml
+++ b/stdlib/pervasives.ml
@@ -153,7 +153,7 @@ let (^) s1 s2 =
external int_of_char : char -> int = "%identity"
external unsafe_char_of_int : int -> char = "%identity"
let char_of_int n =
- if n < 0 or n > 255 then invalid_arg "char_of_int" else unsafe_char_of_int n
+ if n < 0 || n > 255 then invalid_arg "char_of_int" else unsafe_char_of_int n
(* Unit operations *)
@@ -255,7 +255,7 @@ let output_string oc s =
unsafe_output oc s 0 (string_length s)
let output oc s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "output"
else unsafe_output oc s ofs len
@@ -291,7 +291,7 @@ external unsafe_input : in_channel -> string -> int -> int -> int
= "caml_input"
let input ic s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "input"
else unsafe_input ic s ofs len
@@ -304,7 +304,7 @@ let rec unsafe_really_input ic s ofs len =
end
let really_input ic s ofs len =
- if ofs < 0 || len < 0 || ofs + len > string_length s
+ if ofs < 0 || len < 0 || ofs > string_length s - len
then invalid_arg "really_input"
else unsafe_really_input ic s ofs len
diff --git a/stdlib/string.ml b/stdlib/string.ml
index 2cdb83b34..6f2495c7e 100644
--- a/stdlib/string.ml
+++ b/stdlib/string.ml
@@ -38,7 +38,7 @@ let copy s =
r
let sub s ofs len =
- if ofs < 0 || len < 0 || ofs + len > length s
+ if ofs < 0 || len < 0 || ofs > length s - len
then invalid_arg "String.sub"
else begin
let r = create len in
@@ -47,13 +47,13 @@ let sub s ofs len =
end
let fill s ofs len c =
- if ofs < 0 || len < 0 || ofs + len > length s
+ if ofs < 0 || len < 0 || ofs > length s - len
then invalid_arg "String.fill"
else unsafe_fill s ofs len c
let blit s1 ofs1 s2 ofs2 len =
- if len < 0 || ofs1 < 0 || ofs1 + len > length s1
- || ofs2 < 0 || ofs2 + len > length s2
+ if len < 0 || ofs1 < 0 || ofs1 > length s1 - len
+ || ofs2 < 0 || ofs2 > length s2 - len
then invalid_arg "String.blit"
else unsafe_blit s1 ofs1 s2 ofs2 len