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
8e092c40
Commit
8e092c40
authored
Jan 08, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed processing of module option type fields
parent
2689a825
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
module.py
src/binwalk/core/module.py
+19
-9
No files found.
src/binwalk/core/module.py
View file @
8e092c40
...
...
@@ -721,19 +721,29 @@ class Modules(object):
elif
has_key
(
args
,
module_option
.
long
)
and
args
[
module_option
.
long
]
not
in
[
None
,
False
]:
# TODO: There is one module_option.type for many module_option.kwargs. This means that
# all kwargs must be of the same type, else errors can happen in the below processing.
# Fix to check the defined type of each kwarg, and make the module_option.type obsolete.
for
(
name
,
value
)
in
iterator
(
module_option
.
kwargs
):
# Loop through all the kwargs for this command line option
for
(
name
,
default_value
)
in
iterator
(
module_option
.
kwargs
):
# If this kwarg has not been previously processed, or if its priority is equal to or
# greater than the previously processed kwarg's priority, then let's process it.
if
not
has_key
(
last_priority
,
name
)
or
last_priority
[
name
]
<=
module_option
.
priority
:
# Track the priority for future iterations that may process the same kwarg name
last_priority
[
name
]
=
module_option
.
priority
# If the specified type for these kwargs is None, just set the kwarg to its specified default value.
# Else, set it to the value specified from the user.
if
module_option
.
type
is
not
None
:
value
=
args
[
module_option
.
long
]
else
:
value
=
default_value
last_priority
[
name
]
=
module_option
.
priority
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values
# Convert the user-supplied value into the type specified in module_option.type.
# Do this manually as argparse doesn't seem to be able to handle hexadecimal values.
try
:
# Only convert the user-supplied value to a specific type if this kwarg's default
# type is the same as the type specified for the module option.
if
value
!=
default_value
and
type
(
default_value
)
==
module_option
.
type
:
if
module_option
.
type
==
int
:
kwargs
[
name
]
=
int
(
value
,
0
)
elif
module_option
.
type
==
float
:
...
...
@@ -745,11 +755,11 @@ class Modules(object):
elif
module_option
.
type
==
list
:
if
not
has_key
(
kwargs
,
name
):
kwargs
[
name
]
=
[]
# HACK. Fix the above TODO and this check is no longer necessary
if
type
(
kwargs
[
name
])
==
list
:
kwargs
[
name
]
.
append
(
value
)
else
:
kwargs
[
name
]
=
value
else
:
kwargs
[
name
]
=
value
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
...
...
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