Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless _RADIUSAttrPacketListField class #1409

Merged
merged 1 commit into from May 11, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+14 −31
Diff settings

Always

Just for now

Copy path View file
@@ -16,7 +16,7 @@
ShortField, IntField, XIntField, ByteEnumField, StrLenField, XStrField,\
XStrLenField, XStrFixedLenField, LenField, FieldLenField, PacketField,\
PacketListField, ConditionalField, PadField
from scapy.packet import Packet, bind_layers
from scapy.packet import Packet, Padding, bind_layers
from scapy.layers.l2 import SourceMACField, Ether, CookedLinux, GRE, SNAP
from scapy.utils import issubtype
from scapy.config import conf
@@ -279,6 +279,9 @@ def post_build(self, p, pay):
p = p[:2] + chb((l >> 8) & 0xff) + chb(l & 0xff) + p[4:]
return p + pay

def guess_payload_class(self, _):
return Padding


class EAP_MD5(EAP):
"""
Copy path View file
@@ -9,11 +9,10 @@
"""

import struct
import logging
import hashlib
import hmac
from scapy.compat import *
from scapy.packet import Packet, bind_layers
from scapy.compat import orb, raw
from scapy.packet import Packet, Padding, bind_layers
from scapy.fields import ByteField, ByteEnumField, IntField, StrLenField,\
XStrLenField, XStrFixedLenField, FieldLenField, PacketField,\
PacketListField, IPField, MultiEnumField
@@ -278,6 +277,9 @@ def post_build(self, p, pay):
p = p[:1] + struct.pack("!B", length) + p[2:]
return p

def guess_payload_class(self, _):
return Padding


class _SpecificRadiusAttr(RadiusAttribute):
"""
@@ -1055,32 +1057,6 @@ class RadiusAttr_Vendor_Specific(RadiusAttribute):
]


class _RADIUSAttrPacketListField(PacketListField):
"""
PacketListField handling a list of RADIUS attributes.
"""

def getfield(self, pkt, s):
lst = []
length = None
ret = ""

if self.length_from is not None:
length = self.length_from(pkt)

if length is not None:
remain, ret = s[:length], s[length:]

while remain:
attr_len = orb(remain[1])
current = remain[:attr_len]
remain = remain[attr_len:]
packet = self.m2i(pkt, current)
lst.append(packet)

return remain + ret, lst


# See IANA RADIUS Packet Type Codes registry
_packet_codes = {
1: "Access-Request",
@@ -1145,7 +1121,7 @@ class Radius(Packet):
adjust=lambda pkt, x: len(pkt.attributes) + 20
),
XStrFixedLenField("authenticator", "", 16),
_RADIUSAttrPacketListField(
PacketListField(
"attributes",
[],
RadiusAttribute,
Copy path View file
@@ -8877,6 +8877,10 @@ l = PacketList(p)
s = l.sessions() # Crashed on commit: e42ecdc54556c4852ca06b1a6da6c1ccbf3f522e
assert len(s) == 1

= Issue GH#1407
s = b"Z\xa5\xaaUZ\xa5\xaaU\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe9\xc5\x00\x00\x14'\x02\x00\x00\x001\x9a\xe44\xea4"
isinstance(Radius(s), Radius)


############
############
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.