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
07f91a14
Commit
07f91a14
authored
Oct 06, 2020
by
Enkelmann
Committed by
Enkelmann
Nov 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert 1-bit-sized bitvectors to 1-byte-sized bitvectors.
parent
2a56a719
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
10 deletions
+28
-10
bitvector.rs
cwe_checker_rs/src/abstract_domain/bitvector.rs
+8
-8
mod.rs
cwe_checker_rs/src/bil/mod.rs
+5
-1
term.rs
cwe_checker_rs/src/pcode/term.rs
+15
-1
No files found.
cwe_checker_rs/src/abstract_domain/bitvector.rs
View file @
07f91a14
...
...
@@ -176,23 +176,23 @@ impl RegisterDomain for BitvectorDomain {
IntXOr
|
BoolXOr
=>
BitvectorDomain
::
Value
(
lhs_bitvec
^
rhs_bitvec
),
IntEqual
=>
{
assert_eq!
(
lhs_bitvec
.width
(),
rhs_bitvec
.width
());
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
==
rhs_bitvec
))
BitvectorDomain
::
Value
(
Bitvector
::
from
(
(
lhs_bitvec
==
rhs_bitvec
)
as
u8
))
}
IntNotEqual
=>
{
assert_eq!
(
lhs_bitvec
.width
(),
rhs_bitvec
.width
());
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
!=
rhs_bitvec
))
BitvectorDomain
::
Value
(
Bitvector
::
from
(
(
lhs_bitvec
!=
rhs_bitvec
)
as
u8
))
}
IntLess
=>
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
.checked_ult
(
rhs_bitvec
)
.unwrap
(),
lhs_bitvec
.checked_ult
(
rhs_bitvec
)
.unwrap
()
as
u8
,
)),
IntLessEqual
=>
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
.checked_ule
(
rhs_bitvec
)
.unwrap
(),
lhs_bitvec
.checked_ule
(
rhs_bitvec
)
.unwrap
()
as
u8
,
)),
IntSLess
=>
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
.checked_slt
(
rhs_bitvec
)
.unwrap
(),
lhs_bitvec
.checked_slt
(
rhs_bitvec
)
.unwrap
()
as
u8
,
)),
IntSLessEqual
=>
BitvectorDomain
::
Value
(
Bitvector
::
from
(
lhs_bitvec
.checked_sle
(
rhs_bitvec
)
.unwrap
(),
lhs_bitvec
.checked_sle
(
rhs_bitvec
)
.unwrap
()
as
u8
,
)),
FloatEqual
|
FloatNotEqual
|
FloatLess
|
FloatLessEqual
=>
{
// TODO: Implement floating point comparison operators!
...
...
@@ -368,11 +368,11 @@ mod tests {
assert_eq!
(
sixteen
.bin_op
(
IntEqual
,
&
bv
(
16
)),
BitvectorDomain
::
Value
(
Bitvector
::
from_
bit
(
true
))
BitvectorDomain
::
Value
(
Bitvector
::
from_
u8
(
true
as
u8
))
);
assert_eq!
(
sixteen
.bin_op
(
IntNotEqual
,
&
bv
(
16
)),
BitvectorDomain
::
Value
(
Bitvector
::
from_
bit
(
false
))
BitvectorDomain
::
Value
(
Bitvector
::
from_
u8
(
false
as
u8
))
);
assert_eq!
(
sixteen
.un_op
(
Int2Comp
),
bv
(
-
16
));
...
...
cwe_checker_rs/src/bil/mod.rs
View file @
07f91a14
...
...
@@ -243,7 +243,11 @@ impl From<Expression> for IrExpression {
use
Expression
::
*
;
match
expr
{
Var
(
var
)
=>
IrExpression
::
Var
(
var
.into
()),
Const
(
bitvector
)
=>
IrExpression
::
Const
(
bitvector
),
Const
(
bitvector
)
=>
{
// The internal IR expects everything to be byte-sized, so we have to extend the bitvector if necessary.
let
size
:
ByteSize
=
bitvector
.width
()
.into
();
IrExpression
::
Const
(
bitvector
.into_zero_extend
(
apint
::
BitWidth
::
from
(
size
))
.unwrap
())
},
Load
{
..
}
|
Store
{
..
}
|
Let
{
..
}
=>
panic!
(),
IfThenElse
{
true_exp
,
..
}
=>
IrExpression
::
Unknown
{
description
:
"BAP-IfThenElse-expression"
.into
(),
...
...
cwe_checker_rs/src/pcode/term.rs
View file @
07f91a14
...
...
@@ -62,7 +62,21 @@ impl From<Jmp> for IrJmp {
target
:
unwrap_label_direct
(
jmp
.goto
.unwrap
()),
condition
:
jmp
.condition
.unwrap
()
.into
(),
},
BRANCHIND
=>
IrJmp
::
BranchInd
(
unwrap_label_indirect
(
jmp
.goto
.unwrap
())
.into
()),
BRANCHIND
=>
{
let
target
=
unwrap_label_indirect
(
jmp
.goto
.unwrap
());
if
let
Some
(
address
)
=
target
.address
{
// Sometimes there are entries in jump tables that have no associated symbol,
// i.e. jumping there means jumping to nowhere.
// Usually the jump ends up jumping to address 0.
IrJmp
::
CallOther
{
description
:
format!
(
"Unresolved jump: Jump to value read from address {}"
,
address
),
return_
:
None
,
}
}
else
{
IrJmp
::
BranchInd
(
target
.into
())
}
}
CALL
=>
{
let
call
=
jmp
.call
.unwrap
();
IrJmp
::
Call
{
...
...
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