From b26e3936bdbb0082d52c5862142026027cd64eb3 Mon Sep 17 00:00:00 2001
From: Phil <phil@secdev.org>
Date: Fri, 31 Aug 2007 16:43:29 +0200
Subject: [PATCH] Fixes NetBIOSNameField regression due to [4154b5db1e64]
 (ticket #56)

---
 scapy.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scapy.py b/scapy.py
index 4aa086a9..969cb98f 100755
--- a/scapy.py
+++ b/scapy.py
@@ -3852,10 +3852,11 @@ class NetBIOSNameField(StrFixedLenField):
     def __init__(self, name, default, length=31, shift=0):
         StrFixedLenField.__init__(self, name, default, length, shift=shift)
     def i2m(self, pkt, x):
+        l = self.length_from(pkt)/2
         if x is None:
             x = ""
-        x += " "*(self.length/2)
-        x = x[:(self.length/2)]
+        x += " "*(l)
+        x = x[:l]
         x = "".join(map(lambda x: chr(0x41+(ord(x)>>4))+chr(0x41+(ord(x)&0xf)), x))
         x = " "+x
         return x
-- 
GitLab