aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-01-28 15:38:44 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2016-01-28 15:38:44 +0100
commit774977824161f43104f1d31123a0e082395f0fe1 (patch)
tree75f9b17e627720e41b3b7dcf7c026a895d4936fe /cparser
parent2fd25fea96ecb39d2792f463b60fb39594fc75be (diff)
downloadcompcert-774977824161f43104f1d31123a0e082395f0fe1.tar.gz
compcert-774977824161f43104f1d31123a0e082395f0fe1.zip
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.
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Elab.ml2
1 files changed, 1 insertions, 1 deletions
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 =