summaryrefslogtreecommitdiffstats
path: root/stdlib/marshal.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2002-07-12 09:47:54 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2002-07-12 09:47:54 +0000
commitede12e6163058650508a0fbb08177ab4ee4daf02 (patch)
tree6241a927f8d50e772b0cd74ba83e5cdc0d456c5c /stdlib/marshal.ml
parent4865d98f29e1f648c7b45a9304dff12604d6abb8 (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 'stdlib/marshal.ml')
-rw-r--r--stdlib/marshal.ml8
1 files changed, 4 insertions, 4 deletions
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