From 774977824161f43104f1d31123a0e082395f0fe1 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 28 Jan 2016 15:38:44 +0100 Subject: Do test for wrap around on singed ocaml integers. In parse_int it was not tested if the value of v is smaller than zero. This allowed it that certain large integers were accepted due to wrap around. --- cparser/Elab.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cparser/Elab.ml b/cparser/Elab.ml index d58d8be6..aed84a38 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -131,7 +131,7 @@ let parse_int base s = | _ -> assert false in let v = ref 0L in for i = 0 to String.length s - 1 do - if !v > max_val then raise Overflow; + if !v < 0L || !v > max_val then raise Overflow; v := Int64.mul !v (Int64.of_int base); let c = s.[i] in let digit = -- cgit