From: Richard W.M. Jones Date: Fri, 30 Mar 2012 12:49:30 +0000 (+0000) Subject: Permissive subbitstring allows a segmentation fault (issue #16). X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=1f8a6c6db8999dcdec39c15d44884eb36e07e455;p=ocaml-bitstring.git Permissive subbitstring allows a segmentation fault (issue #16). Fix by mrvn. --- diff --git a/bitstring.ml b/bitstring.ml index 1044d89..8a9ef3e 100644 --- a/bitstring.ml +++ b/bitstring.ml @@ -130,7 +130,7 @@ let bitstring_length (_, _, len) = len let subbitstring (data, off, len) off' len' = let off = off + off' in - if len < off' + len' then invalid_arg "subbitstring"; + if off' < 0 || len' < 0 || off' > len - len' then invalid_arg "subbitstring"; (data, off, len') let dropbits n (data, off, len) =