Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cwe_checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
cwe_checker
Commits
5b09cb15
Unverified
Commit
5b09cb15
authored
Feb 12, 2021
by
Enkelmann
Committed by
GitHub
Feb 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pcode mnemonic parsing for CEIL and FLOOR (#147)
parent
b8b08a42
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
29 deletions
+37
-29
graph.rs
cwe_checker_rs/src/analysis/graph.rs
+1
-1
mod.rs
cwe_checker_rs/src/analysis/pointer_inference/context/mod.rs
+9
-9
trait_impls.rs
..._rs/src/analysis/pointer_inference/context/trait_impls.rs
+7
-3
mod.rs
cwe_checker_rs/src/ffi/mod.rs
+1
-1
serde.rs
cwe_checker_rs/src/ffi/serde.rs
+7
-7
term.rs
cwe_checker_rs/src/intermediate_representation/term.rs
+10
-8
expressions.rs
cwe_checker_rs/src/pcode/expressions.rs
+2
-0
No files found.
cwe_checker_rs/src/analysis/graph.rs
View file @
5b09cb15
...
...
@@ -354,7 +354,7 @@ impl<'a> GraphBuilder<'a> {
.term
.jmps
.iter
()
.find
(|
jump
|
matches!
(
jump
.term
,
Jmp
::
Call
{
..
}))
.find
(|
jump
|
matches!
(
jump
.term
,
Jmp
::
Call
{
..
}))
.unwrap
();
let
return_combine_node
=
self
.graph
.add_node
(
Node
::
CallReturn
{
call
:
(
call_block
,
caller_sub
),
...
...
cwe_checker_rs/src/analysis/pointer_inference/context/mod.rs
View file @
5b09cb15
...
...
@@ -129,7 +129,7 @@ impl<'a> Context<'a> {
mut
state
:
State
,
call
:
&
Term
<
Jmp
>
,
extern_symbol
:
&
ExternSymbol
,
)
->
Option
<
State
>
{
)
->
State
{
match
extern_symbol
.get_unique_return_register
()
{
Ok
(
return_register
)
=>
{
let
object_id
=
AbstractIdentifier
::
new
(
...
...
@@ -148,12 +148,12 @@ impl<'a> Context<'a> {
Bitvector
::
zero
(
apint
::
BitWidth
::
from
(
address_bytesize
))
.into
(),
);
state
.set_register
(
return_register
,
pointer
.into
());
Some
(
state
)
state
}
Err
(
err
)
=>
{
// We cannot track the new object, since we do not know where to store the pointer to it.
self
.log_debug
(
Err
(
err
),
Some
(
&
call
.tid
));
Some
(
state
)
state
}
}
}
...
...
@@ -167,7 +167,7 @@ impl<'a> Context<'a> {
mut
new_state
:
State
,
call
:
&
Term
<
Jmp
>
,
extern_symbol
:
&
ExternSymbol
,
)
->
Option
<
State
>
{
)
->
State
{
match
extern_symbol
.get_unique_parameter
()
{
Ok
(
parameter
)
=>
{
let
parameter_value
=
state
.eval_parameter_arg
(
...
...
@@ -205,18 +205,18 @@ impl<'a> Context<'a> {
);
}
new_state
.remove_unreferenced_objects
();
Some
(
new_state
)
new_state
}
Err
(
err
)
=>
{
self
.log_debug
(
Err
(
err
),
Some
(
&
call
.tid
));
Some
(
new_state
)
new_state
}
}
}
Err
(
err
)
=>
{
// We do not know which memory object to free
self
.log_debug
(
Err
(
err
),
Some
(
&
call
.tid
));
Some
(
new_state
)
new_state
}
}
}
...
...
@@ -310,7 +310,7 @@ impl<'a> Context<'a> {
mut
new_state
:
State
,
call
:
&
Term
<
Jmp
>
,
extern_symbol
:
&
ExternSymbol
,
)
->
Option
<
State
>
{
)
->
State
{
self
.log_debug
(
new_state
.clear_stack_parameter
(
extern_symbol
,
...
...
@@ -349,7 +349,7 @@ impl<'a> Context<'a> {
.memory
.assume_arbitrary_writes_to_object
(
id
,
&
possible_referenced_ids
);
}
Some
(
new_state
)
new_state
}
/// Handle a generic call whose target function is unknown.
...
...
cwe_checker_rs/src/analysis/pointer_inference/context/trait_impls.rs
View file @
5b09cb15
...
...
@@ -274,12 +274,16 @@ impl<'a> crate::analysis::forward_interprocedural_fixpoint::Context<'a> for Cont
match
extern_symbol
.name
.as_str
()
{
malloc_like_fn
if
self
.allocation_symbols
.iter
()
.any
(|
x
|
x
==
malloc_like_fn
)
=>
{
self
.add_new_object_in_call_return_register
(
new_state
,
call
,
extern_symbol
)
Some
(
self
.add_new_object_in_call_return_register
(
new_state
,
call
,
extern_symbol
,
))
}
free_like_fn
if
self
.deallocation_symbols
.iter
()
.any
(|
x
|
x
==
free_like_fn
)
=>
{
self
.mark_parameter_object_as_freed
(
state
,
new_state
,
call
,
extern_symbol
)
Some
(
self
.mark_parameter_object_as_freed
(
state
,
new_state
,
call
,
extern_symbol
)
)
}
_
=>
self
.handle_generic_extern_call
(
state
,
new_state
,
call
,
extern_symbol
),
_
=>
Some
(
self
.handle_generic_extern_call
(
state
,
new_state
,
call
,
extern_symbol
)
),
}
}
else
{
panic!
(
"Extern symbol not found."
);
...
...
cwe_checker_rs/src/ffi/mod.rs
View file @
5b09cb15
...
...
@@ -42,7 +42,7 @@ where
/// the finalizer must be attached to it on the Ocaml side!
trait
OcamlSendable
:
std
::
marker
::
Sized
{
/// Pack the object into an Ocaml value
fn
to_ocaml
(
self
)
->
ocaml
::
Value
{
fn
in
to_ocaml
(
self
)
->
ocaml
::
Value
{
let
boxed_val
=
Rc
::
new
(
self
);
ocaml
::
Value
::
nativeint
(
Rc
::
into_raw
(
boxed_val
)
as
isize
)
}
...
...
cwe_checker_rs/src/ffi/serde.rs
View file @
5b09cb15
...
...
@@ -83,7 +83,7 @@ caml!(rs_finalize_json_builder(builder_val) {
/// Build JsonBuilder::Null as Ocaml value
fn
build_serde_null
()
->
ocaml
::
Value
{
JsonBuilder
::
Null
.to_ocaml
()
JsonBuilder
::
Null
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_null
(
_unit
)
{
...
...
@@ -95,7 +95,7 @@ caml!(rs_build_serde_null(_unit) {
/// Build JsonBuilder::Bool as Ocaml value
fn
build_serde_bool
(
bool_val
:
ocaml
::
Value
)
->
ocaml
::
Value
{
let
boolean
:
bool
=
bool
::
from_value
(
bool_val
);
JsonBuilder
::
Bool
(
boolean
)
.to_ocaml
()
JsonBuilder
::
Bool
(
boolean
)
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_bool
(
bool_val
)
{
...
...
@@ -107,7 +107,7 @@ caml!(rs_build_serde_bool(bool_val) {
/// Build JsonBuilder::Number as Ocaml value
fn
build_serde_number
(
num
:
ocaml
::
Value
)
->
ocaml
::
Value
{
let
num
:
isize
=
ocaml
::
Value
::
isize_val
(
&
num
);
JsonBuilder
::
Number
(
num
)
.to_ocaml
()
JsonBuilder
::
Number
(
num
)
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_number
(
number
)
{
...
...
@@ -154,7 +154,7 @@ fn build_serde_bitvector(bitvector_string_val: ocaml::Value) -> ocaml::Value {
(
"width"
.to_string
(),
Rc
::
new
(
JsonBuilder
::
Array
(
width_list
))),
]);
result
.to_ocaml
()
result
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_bitvector
(
bitvector_string
)
{
...
...
@@ -166,7 +166,7 @@ caml!(rs_build_serde_bitvector(bitvector_string) {
/// Build JsonBuilder::String as Ocaml value
fn
build_serde_string
(
string_val
:
ocaml
::
Value
)
->
ocaml
::
Value
{
let
string
=
String
::
from_value
(
string_val
);
JsonBuilder
::
String
(
string
)
.to_ocaml
()
JsonBuilder
::
String
(
string
)
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_string
(
string_val
)
{
...
...
@@ -183,7 +183,7 @@ fn build_serde_array_from_list(list_val: ocaml::Value) -> ocaml::Value {
.into_iter
()
.map
(|
ocaml_val
|
unsafe
{
JsonBuilder
::
from_ocaml_rc
(
&
ocaml_val
)
})
.collect
();
JsonBuilder
::
Array
(
vec
)
.to_ocaml
()
JsonBuilder
::
Array
(
vec
)
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_array_from_list
(
list_val
)
{
...
...
@@ -211,7 +211,7 @@ fn build_serde_object(tuple_list_val: ocaml::Value) -> ocaml::Value {
(
key
,
data
)
})
.collect
();
JsonBuilder
::
Object
(
pairs
)
.to_ocaml
()
JsonBuilder
::
Object
(
pairs
)
.
in
to_ocaml
()
}
caml!
(
rs_build_serde_object
(
tuple_list_val
)
{
...
...
cwe_checker_rs/src/intermediate_representation/term.rs
View file @
5b09cb15
...
...
@@ -80,22 +80,24 @@ impl Term<Def> {
output_sub_register
:
String
,
)
->
Option
<
Tid
>
{
match
&
self
.term
{
Def
::
Assign
{
var
,
value
}
if
output_name
==
var
.name
=>
match
value
{
Expression
::
Cast
{
op
,
arg
,
..
}
=>
{
Def
::
Assign
{
var
,
value
:
Expression
::
Cast
{
op
:
CastOpType
::
IntZExt
,
arg
,
..
},
}
if
output_name
==
var
.name
=>
{
let
argument
:
&
Expression
=
arg
;
match
op
{
CastOpType
::
IntZExt
=>
match
argument
{
match
argument
{
Expression
::
Var
(
var
)
if
var
.name
==
output_sub_register
=>
{
Some
(
self
.tid
.clone
())
}
_
=>
None
,
},
_
=>
None
,
}
}
_
=>
None
,
},
_
=>
None
,
}
}
}
...
...
cwe_checker_rs/src/pcode/expressions.rs
View file @
5b09cb15
...
...
@@ -210,7 +210,9 @@ pub enum ExpressionType {
FLOAT_NEG
,
FLOAT_ABS
,
FLOAT_SQRT
,
#[serde(alias
=
"CEIL"
)]
FLOAT_CEIL
,
#[serde(alias
=
"FLOOR"
)]
FLOAT_FLOOR
,
#[serde(alias
=
"ROUND"
)]
FLOAT_ROUND
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment