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
399ef02c
Unverified
Commit
399ef02c
authored
Aug 30, 2021
by
Enkelmann
Committed by
GitHub
Aug 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not panic on encountered divisions by zero (#215)
parent
428d42d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
bitvector.rs
..._checker_lib/src/intermediate_representation/bitvector.rs
+6
-5
No files found.
src/cwe_checker_lib/src/intermediate_representation/bitvector.rs
View file @
399ef02c
...
...
@@ -94,7 +94,8 @@ impl BitvectorExtended for Bitvector {
}
/// Perform a binary operation on the given bitvectors.
/// Returns an error for non-implemented operations (currently all float-related operations).
/// Returns an error for non-implemented operations (currently all float-related operations)
/// or for divisions-by-zero.
fn
bin_op
(
&
self
,
op
:
BinOpType
,
rhs
:
&
Self
)
->
Result
<
Self
,
Error
>
{
use
BinOpType
::
*
;
match
op
{
...
...
@@ -160,7 +161,7 @@ impl BitvectorExtended for Bitvector {
if
self
.width
()
.to_usize
()
>
64
{
Err
(
anyhow!
(
"Multiplication and division of integers larger than 8 bytes not yet implemented."
))
}
else
{
Ok
(
self
.clone
()
.into_checked_udiv
(
rhs
)
.unwrap
()
)
Ok
(
self
.clone
()
.into_checked_udiv
(
rhs
)
?
)
}
}
IntSDiv
=>
{
...
...
@@ -168,11 +169,11 @@ impl BitvectorExtended for Bitvector {
if
self
.width
()
.to_usize
()
>
64
{
Err
(
anyhow!
(
"Multiplication and division of integers larger than 8 bytes not yet implemented."
))
}
else
{
Ok
(
self
.clone
()
.into_checked_sdiv
(
rhs
)
.unwrap
()
)
Ok
(
self
.clone
()
.into_checked_sdiv
(
rhs
)
?
)
}
}
IntRem
=>
Ok
(
self
.clone
()
.into_checked_urem
(
rhs
)
.unwrap
()
),
IntSRem
=>
Ok
(
self
.clone
()
.into_checked_srem
(
rhs
)
.unwrap
()
),
IntRem
=>
Ok
(
self
.clone
()
.into_checked_urem
(
rhs
)
?
),
IntSRem
=>
Ok
(
self
.clone
()
.into_checked_srem
(
rhs
)
?
),
IntLeft
=>
{
let
shift_amount
=
rhs
.try_to_u64
()
.unwrap
()
as
usize
;
if
shift_amount
<
self
.width
()
.to_usize
()
{
...
...
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