[PATCH] tests: nl80211.py: fix attribute padding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Berg <johannes.berg@xxxxxxxxx>

The kernel started enforcing attribute lengths, and
nl80211.py had been doing it all wrong - the padding
must be present, but not part of the length.

Fix it to do it the right way.

Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
---
 tests/hwsim/nl80211.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/hwsim/nl80211.py b/tests/hwsim/nl80211.py
index 80870d9a2fce..966ea3f0e8da 100644
--- a/tests/hwsim/nl80211.py
+++ b/tests/hwsim/nl80211.py
@@ -320,24 +320,26 @@ nl80211_attr = {
 }
 
 def build_nl80211_attr(id, val):
-    return struct.pack("@HH", 4 + len(val), nl80211_attr[id]) + val
+    attr = struct.pack("@HH", 4 + len(val), nl80211_attr[id]) + val
+    if len(attr) % 4 != 0:
+        attr += '\0' * (4 - len(attr))
+    return attr
 
 def build_nl80211_attr_u32(id, val):
     return build_nl80211_attr(id, struct.pack("@I", val))
 
 def build_nl80211_attr_u16(id, val):
-    return build_nl80211_attr(id, struct.pack("@HH", val, 0))
+    return build_nl80211_attr(id, struct.pack("@H", val))
 
 def build_nl80211_attr_u8(id, val):
-    return build_nl80211_attr(id, struct.pack("@4B", val, 0, 0, 0))
+    return build_nl80211_attr(id, struct.pack("@B", val))
 
 def build_nl80211_attr_flag(id):
     return build_nl80211_attr(id, '')
 
 def build_nl80211_attr_mac(id, val):
     addr = struct.unpack('6B', binascii.unhexlify(val.replace(':','')))
-    t = addr + (0, 0)
-    aval = struct.pack('<6BBB', *t)
+    aval = struct.pack('<6B', *addr)
     return build_nl80211_attr(id, aval)
 
 def parse_nl80211_attrs(msg):
-- 
2.14.2


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux