diff --git a/scapy/layers/sctp.py b/scapy/layers/sctp.py index f20c4b8984649b63e124e5689d359736a60ce63d..94b3f4b398c3ef096cb66a1c1c125403efd17eed 100644 --- a/scapy/layers/sctp.py +++ b/scapy/layers/sctp.py @@ -8,9 +8,9 @@ SCTP (Stream Control Transmission Protocol). """ -import os import struct +from scapy.volatile import RandBin from scapy.config import conf from scapy.packet import * from scapy.fields import * @@ -319,7 +319,7 @@ class SCTPChunkParamRandom(_SCTPChunkParam, Packet): fields_desc = [ ShortEnumField("type", 0x8002, sctpchunkparamtypes), FieldLenField("len", None, length_of="random", adjust = lambda pkt,x:x+4), - PadField(StrLenField("random", os.urandom(32), + PadField(StrLenField("random", RandBin(32), length_from=lambda pkt: pkt.len-4), 4, padwith=b"\x00"),] diff --git a/test/regression.uts b/test/regression.uts index 2dc5fe5d8178bc74fc388e5194f76a30846366c6..8de27d32b5935c15a53aaf5029c7d7d990d33e99 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -7892,6 +7892,11 @@ assert(p.len == 8) assert(p.seq == 0) assert(p.params == []) += SCTPChunkParamRandom - Consecutive calls +~ sctp +param1, param2 = SCTPChunkParamRandom(), SCTPChunkParamRandom() +assert(param1.random != param2.random) + ############ ############ + DHCP