From f88c78de06cfe41ff7493df14aa63e09429e8ffb Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sat, 10 Jan 2015 06:53:25 +0000 Subject: [PATCH] Add padding on packed attributes. --- nl80211.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nl80211.py b/nl80211.py index feeb56f..6aaeeab 100755 --- a/nl80211.py +++ b/nl80211.py @@ -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):