diff --git a/0001-ARMAttribute-fix-access-to-structs-stream-and-nul-20.patch b/0001-ARMAttribute-fix-access-to-structs-stream-and-nul-20.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c45b9dbc2cd315cebc55738a6c2c68cf35bf429 --- /dev/null +++ b/0001-ARMAttribute-fix-access-to-structs-stream-and-nul-20.patch @@ -0,0 +1,53 @@ +From c2f6fe363f0bbeb595946204b3c41d4034126840 Mon Sep 17 00:00:00 2001 +From: Andreas Ziegler +Date: Thu, 25 Oct 2018 14:31:20 +0200 +Subject: [PATCH] ARMAttribute: fix access to structs, stream and nul (#203) + +The __init__ function of ARMAttribute has two parameters +structs and stream through which the caller can pass in the +relevant objects (ARMAttributesSubsubsection does that after +seeking to the right position in stream). + +The accesses for TAG_SECTION and TAG_SYMBOL, however, were +referring to non-existing members instead of the parameters. + +Additionally, one assertion tries to access an undefined +'null_byte' variable which should be 'nul' instead. +--- + elftools/elf/sections.py | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/elftools/elf/sections.py b/elftools/elf/sections.py +index 20e9056..9d16b24 100644 +--- a/elftools/elf/sections.py ++++ b/elftools/elf/sections.py +@@ -287,14 +287,12 @@ class ARMAttribute(object): + + if self.tag != 'TAG_FILE': + self.extra = [] +- s_number = struct_parse(self.structs.Elf_uleb128('s_number'), +- self.stream +- ) ++ s_number = struct_parse(structs.Elf_uleb128('s_number'), stream) + + while s_number != 0: + self.extra.append(s_number) +- s_number = struct_parse(self.structs.Elf_uleb128('s_number'), +- self.stream ++ s_number = struct_parse(structs.Elf_uleb128('s_number'), ++ stream + ) + + elif self.tag in ('TAG_CPU_RAW_NAME', 'TAG_CPU_NAME', 'TAG_CONFORMANCE'): +@@ -313,7 +311,7 @@ class ARMAttribute(object): + + if type(self.value.value) is not str: + nul = struct_parse(structs.Elf_byte('nul'), stream) +- elf_assert(null_byte == 0, ++ elf_assert(nul == 0, + "Invalid terminating byte %r, expecting NUL." % nul) + + else: +-- +2.42.0.windows.2 + diff --git a/pyelftools.spec b/pyelftools.spec index 2720f8c4b79da1cb09b4d39aba3fced739415e66..4c313ff83a4a424afdfe65858c5f4ce0328ad0bc 100644 --- a/pyelftools.spec +++ b/pyelftools.spec @@ -1,6 +1,6 @@ Name: pyelftools Version: 0.25 -Release: 3 +Release: 4 License: Public Domain Summary: Pure-Python library for parsing and analyzing ELF files URL: https://github.com/eliben/pyelftools @@ -9,6 +9,8 @@ Source0: https://files.pythonhosted.org/packages/source/p/pyelftools/pyel BuildRequires: python3-devel python3-setuptools BuildArch: noarch +Patch0001: 0001-ARMAttribute-fix-access-to-structs-stream-and-nul-20.patch + %description This package provides a python library for parsing and analyzing ELF files and DWARF debugging information. @@ -44,6 +46,9 @@ mv %{buildroot}/usr/bin/readelf.py %{buildroot}/usr/bin/pyreadelf %changelog +* Thu Jan 11 2024 liubo - 0.25-4 +- ARMAttribute: fix access to structs, stream and nul + * Wed Oct 21 2020 wutao - 0.25-3 - delete python2 modules