Add padding on packed attributes.

This commit is contained in:
Ian Gulliver
2015-01-10 06:53:25 +00:00
parent eed19490e9
commit f88c78de06

View File

@@ -127,9 +127,14 @@ class Attribute(object):
sub_parser = self._attributes[attrtype][1]
sub_accumulator = Accumulator()
sub_parser.Pack(sub_accumulator, value)
self._nlattr.Pack(accumulator, len=self._nlattr.size + len(sub_accumulator), type=attrtype)
attrlen = self._nlattr.size + len(sub_accumulator)
self._nlattr.Pack(accumulator, len=attrlen, type=attrtype)
accumulator.Append(str(sub_accumulator))
padding = ((attrlen + 4 - 1) & ~3) - attrlen
if padding:
accumulator.Append('\0' * padding)
class Attributes(object):
def __init__(self, attributes):