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
a5bfe605
Commit
a5bfe605
authored
7 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added more robust sanity checking for CPIO results
parent
f636501d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
cpio.py
src/binwalk/plugins/cpio.py
+11
-5
No files found.
src/binwalk/plugins/cpio.py
View file @
a5bfe605
...
...
@@ -72,17 +72,23 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
return
name
def
_get_file_name_length
(
self
,
description
):
length
=
0
length
=
None
if
'file name length: "'
in
description
:
length_string
=
description
.
split
(
'file name length: "'
)[
1
]
.
split
(
'"'
)[
0
]
length
=
int
(
length_string
,
0
)
try
:
length
=
int
(
length_string
,
0
)
except
ValueError
:
pass
return
length
def
_get_file_size
(
self
,
description
):
size
=
0
size
=
None
if
'file size: "'
in
description
:
size_string
=
description
.
split
(
'file size: "'
)[
1
]
.
split
(
'"'
)[
0
]
size
=
int
(
size_string
,
0
)
try
:
size
=
int
(
size_string
,
0
)
except
ValueError
:
pass
return
size
def
scan
(
self
,
result
):
...
...
@@ -99,7 +105,7 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
file_name_length
=
self
.
_get_file_name_length
(
result
.
description
)
# The +1 is to include the terminating NULL byte
if
file_name_length
!=
len
(
file_name
)
+
1
:
if
None
in
[
file_size
,
file_name_length
]
or
file_name_length
!=
len
(
file_name
)
+
1
:
# If the reported length of the file name doesn't match the actual
# file name length, treat this as a false positive result.
result
.
valid
=
False
...
...
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