Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
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
binwalk
Commits
a133a6fd
Commit
a133a6fd
authored
10 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed MathExpression bugs
parent
68812ce2
master
…
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.1
python27
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
common.py
src/binwalk/core/common.py
+7
-3
magic.py
src/binwalk/core/magic.py
+1
-1
No files found.
src/binwalk/core/common.py
View file @
a133a6fd
...
...
@@ -179,6 +179,8 @@ class MathExpression(object):
OPERATORS
=
{
ast
.
Add
:
op
.
add
,
ast
.
UAdd
:
op
.
add
,
ast
.
USub
:
op
.
sub
,
ast
.
Sub
:
op
.
sub
,
ast
.
Mult
:
op
.
mul
,
ast
.
Div
:
op
.
truediv
,
...
...
@@ -195,7 +197,7 @@ class MathExpression(object):
self
.
value
=
self
.
evaluate
(
self
.
expression
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
except
Exception
as
e
:
pass
def
evaluate
(
self
,
expr
):
...
...
@@ -205,9 +207,11 @@ class MathExpression(object):
if
isinstance
(
node
,
ast
.
Num
):
# <number>
return
node
.
n
elif
isinstance
(
node
,
ast
.
operator
):
# <operator>
return
self
.
OPERATORS
[
type
(
node
)]
return
self
.
OPERATORS
[
type
(
node
.
op
)]
elif
isinstance
(
node
,
ast
.
UnaryOp
):
return
self
.
OPERATORS
[
type
(
node
.
op
)](
0
,
self
.
_eval
(
node
.
operand
))
elif
isinstance
(
node
,
ast
.
BinOp
):
# <left> <operator> <right>
return
self
.
_eval
(
node
.
op
)
(
self
.
_eval
(
node
.
left
),
self
.
_eval
(
node
.
right
))
return
self
.
OPERATORS
[
type
(
node
.
op
)]
(
self
.
_eval
(
node
.
left
),
self
.
_eval
(
node
.
right
))
else
:
raise
TypeError
(
node
)
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/core/magic.py
View file @
a133a6fd
...
...
@@ -513,7 +513,7 @@ class Magic(object):
# Sanity check
if
not
isinstance
(
line_offset
,
int
):
raise
ParserException
(
"Failed to convert offset '
%
s' to a number
"
%
line
.
offset
)
raise
ParserException
(
"Failed to convert offset '
%
s' to a number
: '
%
s'"
%
(
line
.
offset
,
line
.
text
)
)
# The start of the data needed by this line is at offset + line_offset.
# The end of the data will be line.size bytes later.
...
...
This diff is collapsed.
Click to expand it.
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