Commit cd4c6423 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Don't assume all files called ".a" are ELF binaries because we specified a...

Don't assume all files called ".a" are ELF binaries because we specified a FILE_EXTENSION_SUFFIX. This prevents an "Unrecognized archive format" traceback when processing (for example) lie 2.2.2+dfsg-3. (Closes: #903446)
parent 96243190
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -581,6 +581,8 @@ class StaticLibFile(File):
    FILE_TYPE_RE = re.compile(r'\bar archive\b')
    FILE_EXTENSION_SUFFIX = '.a'

    ENABLE_FALLBACK_RECOGONIZES = False

    def compare_details(self, other, source=None):
        differences = [Difference.from_text_readers(
            list_libarchive(self.path),
+4 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ class File(object, metaclass=abc.ABCMeta):

        return _run_tests(all, all_tests) if all_tests else False

    ENABLE_FALLBACK_RECOGONIZES = True
    FALLBACK_FILE_EXTENSION_SUFFIX = None
    FALLBACK_FILE_TYPE_HEADER_PREFIX = None

@@ -176,6 +177,9 @@ class File(object, metaclass=abc.ABCMeta):
            # not valid, they have to re-implement it
            return False

        if not cls.ENABLE_FALLBACK_RECOGONIZES:
            return False

        all_tests = [test for test in (
            (cls.FALLBACK_FILE_EXTENSION_SUFFIX,
             str.endswith, file.name),
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ from ..utils.tools import skip_unless_tools_exist, \

obj1 = load_fixture('test1.o')
obj2 = load_fixture('test2.o')
bug_903446 = load_fixture('bug_903446.a')


def readelf_version():
@@ -184,3 +185,11 @@ def test_original_gnu_debuglink(dbgsym_differences):
    assert '.gnu_debuglink' in bin_details.details[2].source1
    expected_gnu_debuglink = get_data('gnu_debuglink_expected_diff')
    assert bin_details.details[2].unified_diff == expected_gnu_debuglink


def test_bug_903446(bug_903446):
    # Ensure we don't error
    bug_903446.compare(bug_903446)

    # Not a real StaticLibFile
    assert isinstance(bug_903446, FilesystemFile)
+79.2 KiB

File added.

No diff preview for this file type.