Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
738ceae6
Commit
738ceae6
authored
1 year ago
by
Thibault Martin
Committed by
Virgile Prevosto
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Check if array length is too large in cabs2cil
parent
d8829739
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_internals/typing/cabs2cil.ml
+22
-3
22 additions, 3 deletions
src/kernel_internals/typing/cabs2cil.ml
with
22 additions
and
3 deletions
src/kernel_internals/typing/cabs2cil.ml
+
22
−
3
View file @
738ceae6
...
@@ -4794,9 +4794,28 @@ and doType (ghost:bool) isFuncArg
...
@@ -4794,9 +4794,28 @@ and doType (ghost:bool) isFuncArg
let
cst
=
constFold
true
len'
in
let
cst
=
constFold
true
len'
in
(
match
cst
.
enode
with
(
match
cst
.
enode
with
|
Const
(
CInt64
(
i
,
_
,
_
))
->
|
Const
(
CInt64
(
i
,
_
,
_
))
->
if
Integer
.
lt
i
Integer
.
zero
then
begin
Kernel
.
error
~
once
:
true
~
current
:
true
if
Integer
.
lt
i
Integer
.
zero
then
"Array length is negative."
Kernel
.
error
~
once
:
true
~
current
:
true
"Array length is negative."
else
try
(* Check if array length is > SIZE_MAX / sizeof(bt) *)
let
elem_size
=
Integer
.
of_int
@@
bytesSizeOf
bt
in
let
size_t
=
bitsSizeOfInt
theMachine
.
kindOfSizeOf
in
let
size_max
=
Cil
.
max_unsigned_number
size_t
in
let
limit
=
Integer
.
c_div
size_max
elem_size
in
if
Integer
.
gt
i
limit
then
Kernel
.
error
~
once
:
true
~
current
:
true
"Array length is too large."
;
with
|
SizeOfError
(
msg
,_
)
->
Kernel
.
abort
~
current
:
true
"%s"
msg
|
Invalid_argument
msg
->
Kernel
.
fatal
~
current
:
true
"%s"
msg
|
Division_by_zero
->
Kernel
.
fatal
~
current
:
true
"Array element size cannot be zero"
end
|
_
when
not
allowVarSizeArrays
->
|
_
when
not
allowVarSizeArrays
->
if
isConstant
cst
then
if
isConstant
cst
then
(* e.g., there may be a float constant involved.
(* e.g., there may be a float constant involved.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment