Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scapy/layers/ms_nrtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from scapy.automaton import Automaton, ATMT
from scapy.config import conf
from scapy.error import Scapy_Exception
from scapy.main import interact
from scapy.fields import (
ByteEnumField,
Expand Down Expand Up @@ -337,6 +338,11 @@ def __init__(self, name, default, length_of=None):
FieldLenField.__init__(self, name, default, length_of=length_of)
super(MSBExtendedFieldLen, self).__init__(name, default)

def getfield(self, pkt, s):
if len(s) >= 5 and min(s[:4]) >= 0x80 and s[4] > 0x07:
raise Scapy_Exception("NRBF string length exceeds 31 bits")
return super(MSBExtendedFieldLen, self).getfield(pkt, s)

i2m = FieldLenField.i2m


Expand Down
11 changes: 11 additions & 0 deletions test/scapy/layers/msnrtp.uts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ assert pkt.records[3].Values == b"TRIMMED"

assert isinstance(pkt.records[4], NRBFMessageEnd)

= [MS-NRBF] reject a string length wider than 31 bits

# The over-wide length is meant to be rejected and fall back to Raw, so the
# debug dissector must not turn that rejection into a raised exception.
with no_debug_dissector():
pkt = NRBF(b"\x0c\x01\x00\x00\x00" + b"\x81" * 5)
assert isinstance(pkt.records[0], Raw)

maximum = NRBFLengthPrefixedString(b"\xff\xff\xff\xff\x07")
assert maximum.Length == 0x7fffffff

= [MS-NRBF] build .NET Binary Format

pkt = NRBF(
Expand Down
Loading