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-gitdep
binwalk
Commits
a133a6fd
Commit
a133a6fd
authored
Nov 11, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed MathExpression bugs
parent
68812ce2
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
)
...
...
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.
...
...
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