Skip to content

Commit

Permalink
[FEATURE] Do not proceed if base not set. Skip prefix in hex validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Jan 20, 2022
1 parent c85b48d commit 369c8db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ifl.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def va_to_rva(va: int) -> int:


def _is_hex_str(s):
# skip prefix:
if s[:2] == "0x":
s = s[2:]
# validate hex charset:
hex_digits = set("0123456789abcdefABCDEF")
for val in s:
if not (val in hex_digits):
Expand Down Expand Up @@ -1306,9 +1310,11 @@ def importNames(self) -> None:
default_base = idaapi.get_imagebase()
base_str, ok = QtWidgets.QInputDialog.getText(None, "Set base:", "Current module base:", QtWidgets.QLineEdit.Normal, hex(default_base))
if not ok:
load_base = default_base
else:
return
if _is_hex_str(base_str):
load_base = int(base_str, 16)
else:
load_base = default_base
names = self._loadFunctionsNames(file_name, ext, load_base)
if names is None:
idaapi.warning(f"Malformed file %s" % file_name)
Expand Down

0 comments on commit 369c8db

Please sign in to comment.