Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Even if we don't raise an exception (still discussing about it) we need
to manage properly the cases were the binary was not setup.
  • Loading branch information
ValekoZ committed Jan 30, 2024
1 parent 98519c9 commit 814e198
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3335,7 +3335,7 @@ class MIPS64(MIPS):

@staticmethod
def supports_gdb_arch(gdb_arch: str) -> Optional[bool]:
return gdb_arch.startswith("mips") and gef.binary.e_class == Elf.Class.ELF_64_BITS
return gdb_arch.startswith("mips") and gef.binary and gef.binary.e_class == Elf.Class.ELF_64_BITS


def copy_to_clipboard(data: bytes) -> None:
Expand Down Expand Up @@ -3722,7 +3722,7 @@ def reset_architecture(arch: Optional[str] = None) -> None:
return

# last resort, use the info from elf header to find it from the known architectures
if gef.binary.e_machine:
if gef.binary and gef.binary.e_machine:
try:
gef.arch = arches[gef.binary.e_machine]()
except KeyError:
Expand Down Expand Up @@ -7222,7 +7222,7 @@ def do_invoke(self, argv: List[str]) -> None:
return

if not os.access(fpath, os.X_OK):
warn(f"The file '{fpath}' is not executable.")
warn(f"The file '{fpath}' does not exists or is not executable.")
return

if is_alive() and not gef.session.qemu_mode:
Expand Down Expand Up @@ -11114,9 +11114,10 @@ def setup(self) -> bool:
# refresh gef to consider the binary
reset_all_caches()

if self.file.exists():
if self.lfile.exists():
gef.binary = Elf(self.lfile)


reset_architecture()
return success

Expand Down

0 comments on commit 814e198

Please sign in to comment.