Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed extractor.py module #633

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/binwalk/modules/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def extract(self, offset, description, file_name, size, name=None):
# Only clean up files if remove_after_execute was specified.
# Only clean up files if the file was extracted sucessfully, or if we've run
# out of extractors.
if self.remove_after_execute and (extract_ok == True or i == (len(rules) - 1)):
if self.remove_after_execute and (extract_ok or i == (len(rules) - 1)):

# Remove the original file that we extracted,
# if it has not been modified by the extractor.
Expand All @@ -695,7 +695,7 @@ def extract(self, offset, description, file_name, size, name=None):
os.unlink(fname)
except KeyboardInterrupt as e:
raise e
except Exception as e:
except Exception:
pass

# If the command executed OK, don't try any more rules
Expand Down Expand Up @@ -852,7 +852,7 @@ def _dd(self, file_name, offset, size, extension, output_file_name=None):
fdout = BlockFile(fname, 'w')
except KeyboardInterrupt as e:
raise e
except Exception as e:
except Exception:
# Fall back to the default name if the requested name fails
fname = unique_file_name(default_bname, extension)
fdout = BlockFile(fname, 'w')
Expand Down Expand Up @@ -966,22 +966,22 @@ def shell_call(self, command):

# Fork a child process
child_pid = os.fork()
if child_pid is 0:
if child_pid == 0:
# Switch to the run-as user privileges, if one has been set
if self.runas_uid is not None and self.runas_gid is not None:
os.setgid(self.runas_uid)
os.setuid(self.runas_gid)
else:
# child_pid of None indicates that no os.fork() occured
child_pid = None

# If we're the child, or there was no os.fork(), execute the command
if child_pid in [0, None]:
binwalk.core.common.debug("subprocess.call(%s, stdout=%s, stderr=%s)" % (command, str(tmp), str(tmp)))
rval = subprocess.call(shlex.split(command), stdout=tmp, stderr=tmp)

# A true child process should exit with the subprocess exit value
if child_pid is 0:
if child_pid == 0:
sys.exit(rval)
# If no os.fork() happened, just return the subprocess exit value
elif child_pid is None:
Expand All @@ -993,7 +993,7 @@ def shell_call(self, command):
def symlink_sanitizer(self, file_list, extraction_directory):
# User can disable this if desired
if self.do_not_sanitize_symlinks is True:
return
return

# Allows either a single file path, or a list of file paths to be passed in for sanitization.
if type(file_list) is not list:
Expand Down