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
785736f3
Unverified
Commit
785736f3
authored
Nov 02, 2021
by
Enkelmann
Committed by
GitHub
Nov 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always check for implicit Stores in P-Code instructions (#251)
parent
e8251916
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
35 deletions
+61
-35
term.rs
src/cwe_checker_lib/src/pcode/term.rs
+38
-35
tests.rs
src/cwe_checker_lib/src/pcode/term/tests.rs
+23
-0
No files found.
src/cwe_checker_lib/src/pcode/term.rs
View file @
785736f3
...
...
@@ -141,46 +141,49 @@ impl Def {
pub
fn
into_ir_def
(
self
,
generic_pointer_size
:
ByteSize
)
->
IrDef
{
use
super
::
ExpressionType
::
*
;
match
self
.rhs.mnemonic
{
LOAD
=>
IrDef
::
Load
{
var
:
self
.lhs
.unwrap
()
.into
(),
address
:
self
.rhs.input1
.unwrap
()
.into
(),
},
STORE
=>
IrDef
::
Store
{
address
:
self
.rhs.input1
.unwrap
()
.into
(),
value
:
self
.rhs.input2
.unwrap
()
.into
(),
},
SUBPIECE
=>
IrDef
::
Assign
{
var
:
self
.lhs
.clone
()
.unwrap
()
.into
(),
value
:
IrExpression
::
Subpiece
{
low_byte
:
self
.rhs.input1
.unwrap
()
.parse_to_bytesize
(),
size
:
self
.lhs
.unwrap
()
.size
,
arg
:
Box
::
new
(
self
.rhs.input0
.unwrap
()
.into
()),
},
LOAD
=>
{
return
IrDef
::
Load
{
var
:
self
.lhs
.unwrap
()
.into
(),
address
:
self
.rhs.input1
.unwrap
()
.into
(),
}
}
STORE
=>
{
return
IrDef
::
Store
{
address
:
self
.rhs.input1
.unwrap
()
.into
(),
value
:
self
.rhs.input2
.unwrap
()
.into
(),
}
}
_
=>
(),
}
let
target_var
=
self
.lhs
.unwrap
();
let
value
=
match
self
.rhs.mnemonic
{
LOAD
|
STORE
=>
unreachable!
(),
SUBPIECE
=>
IrExpression
::
Subpiece
{
low_byte
:
self
.rhs.input1
.unwrap
()
.parse_to_bytesize
(),
size
:
target_var
.size
,
arg
:
Box
::
new
(
self
.rhs.input0
.unwrap
()
.into
()),
},
INT_ZEXT
|
INT_SEXT
|
INT2FLOAT
|
FLOAT2FLOAT
|
TRUNC
|
POPCOUNT
=>
IrDef
::
Assign
{
var
:
self
.lhs
.clone
()
.unwrap
()
.into
(),
value
:
IrExpression
::
Cast
{
INT_ZEXT
|
INT_SEXT
|
INT2FLOAT
|
FLOAT2FLOAT
|
TRUNC
|
POPCOUNT
=>
{
IrExpression
::
Cast
{
op
:
self
.rhs.mnemonic
.into
(),
size
:
self
.lhs
.unwrap
()
.size
,
size
:
target_var
.size
,
arg
:
Box
::
new
(
self
.rhs.input0
.unwrap
()
.into
()),
},
},
_
=>
{
let
target_var
=
self
.lhs
.unwrap
();
if
target_var
.address
.is_some
()
{
IrDef
::
Store
{
address
:
IrExpression
::
Const
(
target_var
.parse_address_to_bitvector
(
generic_pointer_size
),
),
value
:
self
.rhs
.into
(),
}
}
else
{
IrDef
::
Assign
{
var
:
target_var
.into
(),
value
:
self
.rhs
.into
(),
}
}
}
_
=>
self
.rhs
.into
(),
};
if
target_var
.address
.is_some
()
{
IrDef
::
Store
{
address
:
IrExpression
::
Const
(
target_var
.parse_address_to_bitvector
(
generic_pointer_size
),
),
value
,
}
}
else
{
IrDef
::
Assign
{
var
:
target_var
.into
(),
value
,
}
}
}
}
...
...
src/cwe_checker_lib/src/pcode/term/tests.rs
View file @
785736f3
...
...
@@ -438,6 +438,29 @@ fn def_deserialization() {
}
#[test]
fn
def_deserialization_issue_247_regression_test
()
{
let
def
:
Def
=
serde_json
::
from_str
(
r
#
"{
"
lhs
": {
"
address
": "
15
f0499e
",
"
size
": 2,
"
is_virtual
": false
},
"
rhs
": {
"
mnemonic
": "
TRUNC
",
"
input0
": {
"
name
": "
$
U5df80
",
"
size
": 10,
"
is_virtual
": true
}
}
}"
#
,
)
.unwrap
();
let
_
:
IrDef
=
def
.into_ir_def
(
ByteSize
::
new
(
8
));
}
#[test]
fn
label_deserialization
()
{
let
_
:
Label
=
serde_json
::
from_str
(
r
#
"
...
...
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