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

small fixes in reset_architecture() #834

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
8 changes: 6 additions & 2 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3771,7 +3771,11 @@ def reset_architecture(arch: Optional[str] = None, default: Optional[str] = None
raise OSError(f"Specified arch {arch.upper()} is not supported")

if not gef.binary:
gef.binary = get_elf_headers()
try:
gef.binary = get_elf_headers()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a bad idea: gef.binary is literally used all the time and safe-failing that way (i.e. allowing gef.binary to be None) would open up plenty of error scenario where we assume it can't be.

What are the reasons behind this?

except RuntimeError:
# in case the binary is not an ELF file
abgeana marked this conversation as resolved.
Show resolved Hide resolved
pass

gdb_arch = get_arch()
arch_name = gef.binary.e_machine if gef.binary else gdb_arch
Expand All @@ -3782,7 +3786,7 @@ def reset_architecture(arch: Optional[str] = None, default: Optional[str] = None
return

try:
gef.arch = arches[arch_name]()
gef.arch = arches[arch_name.upper()]()
abgeana marked this conversation as resolved.
Show resolved Hide resolved
except KeyError:
if default:
try:
Expand Down