Skip to content

Commit

Permalink
Fix error when loading non-UTF data
Browse files Browse the repository at this point in the history
  • Loading branch information
toolCHAINZ committed Oct 3, 2020
1 parent c77ef8b commit e49eff3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
9 changes: 5 additions & 4 deletions ihex_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ class IHexView(BinaryView):
name = "Intel HEX"
@classmethod
def is_valid_for_data(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
if is_ihex(actual_data):
return True
return False
try:
actual_data = data.read(0, len(data)).decode('utf8')
return is_ihex(actual_data)
except:
return False

def __init__(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"Windows": "`py -m pip install bincopy`",
"Linux": "`pip install bincopy`"
},
"version": "1.0.1",
"version": "1.0.2",
"minimumbinaryninjaversion": 2170
}
9 changes: 5 additions & 4 deletions srec_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ class SRECView(BinaryView):
name = "Motorola SREC"
@classmethod
def is_valid_for_data(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
if is_srec(actual_data):
return True
return False
try:
actual_data = data.read(0, len(data)).decode('utf8')
return is_srec(actual_data)
except:
return False

def __init__(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
Expand Down
9 changes: 5 additions & 4 deletions ti_txt_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ class TiTxtView(BinaryView):
name = "TI HEX"
@classmethod
def is_valid_for_data(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
if is_ti_txt(actual_data):
return True
return False
try:
actual_data = data.read(0, len(data)).decode('utf8')
return is_ti_txt(actual_data)
except:
return False

def __init__(self, data: BinaryView):
actual_data = data.read(0, len(data)).decode('utf8')
Expand Down

0 comments on commit e49eff3

Please sign in to comment.