Skip to content

Commit

Permalink
Ensure that the length < 256 and > 3 for the deflate function
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Feb 25, 2017
1 parent 869532e commit ab88ecc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/decompress.ml
Expand Up @@ -368,6 +368,11 @@ struct
let await t lst = Wait (t, lst)
let error t exn = Error ({ t with state = Exception exn }, exn)

let _max_distance = 8191
let _max_length = 256
let _size_of_int64 = 8
let _idx_boundary = 2

type key = Int32.t option

let key src idx len : key =
Expand All @@ -388,7 +393,8 @@ struct

let longuest_substring src x y len =
let rec aux acc l =
if x + l < y
if l < _max_length
&& x + l < y
&& y + l < len
&& Safe.get src (x + l) = Safe.get src (y + l)
then aux (Some (l + 1)) (l + 1)
Expand Down Expand Up @@ -436,8 +442,8 @@ struct
|| idx - x >= max_fardistance
then acc
else match longuest_substring src x idx (t.i_off + t.i_len) with
| None -> aux acc r
| Some len -> aux (max acc (Some (x, len))) r
| Some len when len >= 3 -> aux (max acc (Some (x, len))) r
| _ -> aux acc r
in

match aux None candidates with
Expand Down Expand Up @@ -467,11 +473,6 @@ struct

let _hlog = [| 0; 11; 11; 11; 12; 13; 13; 13; 13; 13 |]

let _max_distance = 8191
let _max_length = 256
let _size_of_int64 = 8
let _idx_boundary = 2

(* Same as blosclz, fast and imperative implementation *)
let deffast
: type a.
Expand Down

0 comments on commit ab88ecc

Please sign in to comment.