| |
@@ -689,7 +689,8 @@
|
| |
dl = multibyte(data[4:8])
|
| |
|
| |
# read the index (starts at offset 16)
|
| |
- index = {}
|
| |
+ index = []
|
| |
+ tag_index = {}
|
| |
for i in range(il):
|
| |
entry = []
|
| |
for j in range(4):
|
| |
@@ -698,21 +699,22 @@
|
| |
entry.append(multibyte(data))
|
| |
|
| |
# print("Tag: %d, Type: %d, Offset: %x, Count: %d" % tuple(entry))
|
| |
- index[entry[0]] = entry
|
| |
+ index.append(entry)
|
| |
+ tag_index[entry[0]] = entry
|
| |
+ # in case of duplicate tags, last one wins
|
| |
+
|
| |
self.datalen = dl
|
| |
- self.index = index
|
| |
+ self._store = 16 + il * 16
|
| |
+ self._index = index # list
|
| |
+ self.index = tag_index # dict
|
| |
|
| |
def dump(self, sig=None):
|
| |
print("HEADER DUMP:")
|
| |
- # calculate start of store
|
| |
- il = len(self.index)
|
| |
- store = 16 + il * 16
|
| |
- # print("start is: %d" % start)
|
| |
- # print("index length: %d" % il)
|
| |
- print("Store at offset %d (%0x)" % (store, store))
|
| |
+ store = self._store
|
| |
+ print("Store at offset %d (0x%0x)" % (store, store))
|
| |
# sort entries by offset, dtype
|
| |
# also rearrange: tag, dtype, offset, count -> offset, dtype, tag, count
|
| |
- order = sorted([(x[2], x[1], x[0], x[3]) for x in six.itervalues(self.index)])
|
| |
+ order = sorted([(x[2], x[1], x[0], x[3]) for x in self._index])
|
| |
# map some rpmtag codes
|
| |
tags = {}
|
| |
if rpm:
|
| |
@@ -868,9 +870,7 @@
|
| |
def _getitem(self, dtype, offset, count, decode=None):
|
| |
if decode is None:
|
| |
decode = self.decode
|
| |
- # calculate start of store
|
| |
- il = len(self.index)
|
| |
- store = 16 + il * 16
|
| |
+ store = self._store
|
| |
pos = store + offset
|
| |
if dtype >= 2 and dtype <= 5:
|
| |
values = []
|
| |
For context, see https://pagure.io/koji/issue/4200
If an rpm has duplicate tags in a header, Koji would miscalculate the
start of that data store.
Fixes https://pagure.io/koji/issue/4203