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
d6e09d49
Commit
d6e09d49
authored
Oct 22, 2014
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Python3 bugs in lzmavalid and zlibextract plugins
parent
2e4a21ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
lzmavalid.py
src/binwalk/plugins/lzmavalid.py
+9
-5
zlibextract.py
src/binwalk/plugins/zlibextract.py
+3
-2
No files found.
src/binwalk/plugins/lzmavalid.py
View file @
d6e09d49
import
lzma
import
binwalk.core.plugin
import
binwalk.core.compat
from
binwalk.core.common
import
BlockFile
class
LZMAPlugin
(
binwalk
.
core
.
plugin
.
Plugin
):
...
...
@@ -18,15 +19,18 @@ class LZMAPlugin(binwalk.core.plugin.Plugin):
def
is_valid_lzma
(
self
,
data
):
valid
=
True
# The only acceptable exception is that of IOError "unknown BUF error",
# which indicates that the input data was truncated.
# The only acceptable exceptions are those indicating that the input data was truncated.
try
:
d
=
lzma
.
decompress
(
data
)
lzma
.
decompress
(
binwalk
.
core
.
compat
.
str2bytes
(
data
)
)
except
IOError
as
e
:
if
e
.
message
!=
"unknown BUF error"
:
# The Python2 module gives this error on truncated input data.
if
str
(
e
)
!=
"unknown BUF error"
:
valid
=
False
except
Exception
as
e
:
valid
=
False
# The Python3 module gives this error on truncated input data.
# The inconsistency between modules is a bit worrisome.
if
str
(
e
)
!=
"Compressed data ended before the end-of-stream marker was reached"
:
valid
=
False
return
valid
...
...
src/binwalk/plugins/zlibextract.py
View file @
d6e09d49
import
os
import
zlib
import
binwalk.core.compat
import
binwalk.core.common
import
binwalk.core.plugin
...
...
@@ -25,12 +26,12 @@ class ZLIBExtractPlugin(binwalk.core.plugin.Plugin):
fpin
=
binwalk
.
core
.
common
.
BlockFile
(
fname
)
fpout
=
binwalk
.
core
.
common
.
BlockFile
(
outfile
,
'w'
)
plaintext
=
zlib
.
decompress
(
fpin
.
read
(
))
plaintext
=
zlib
.
decompress
(
binwalk
.
core
.
compat
.
str2bytes
(
fpin
.
read
()
))
fpout
.
write
(
plaintext
)
fpin
.
close
()
fpout
.
close
()
except
Exception
,
e
:
except
Exception
as
e
:
return
False
return
True
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