From 9f8e4a9b7a73d3c32a2f565cab2cbfe0a52ae410 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Thu, 22 Oct 2020 16:58:11 +0000 Subject: Fix #2047; open_view/get_view_of_file_with_options return a raw view if header parsing or getting load options fail --- python/binaryview.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/binaryview.py b/python/binaryview.py index a53cbf35..5356b8c7 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -760,7 +760,7 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)): @classmethod def get_view_of_file(cls, filename, update_analysis=True, progress_func=None): """ - ``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view matches + ``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view is available :param str filename: path to filename or bndb to open :param bool update_analysis: whether or not to run :func:`update_analysis_and_wait` after opening a :py:class:`BinaryView`, defaults to ``True`` @@ -859,6 +859,9 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)): load_settings = view.get_load_settings(bvt.name) if load_settings is None: load_settings = bvt.get_load_settings_for_data(view) + if load_settings is None: + log.log_error(f"Could not get load settings for binary view of type `{bvt.name}`") + return view load_settings.set_resource_id(bvt.name) view.set_load_settings(bvt.name, load_settings) @@ -878,7 +881,9 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)): else: bv = bvt.create(view) - if bv is not None and update_analysis: + if bv is None: + return view + elif update_analysis: bv.update_analysis_and_wait() return bv -- cgit v1.3.1