ARMAttribute: fix access to structs, stream and nul (#203)
authorAndreas Ziegler <ziegler@einserver.de>
Thu, 25 Oct 2018 12:31:20 +0000 (14:31 +0200)
committerEli Bendersky <eliben@users.noreply.github.com>
Thu, 25 Oct 2018 12:31:20 +0000 (05:31 -0700)
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

index 20e90562e60e6e20a7ab1e27df17df01799ac2bb..9d16b241fa5bb63a032b2ac71c3e0e0d700f559e 100644 (file)
@@ -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: