Raise ValueError in case unpack_from returns zero length

Merge-conflicts:
os_ken/ofproto/ofproto_v1_3_parser.py
os_ken/ofproto/ofproto_v1_4_parser.py
os_ken/ofproto/ofproto_v1_5_parser.py

Closes-Bug: #2067973
Closes-Bug: #2067970
Change-Id: If3327be6c0a4c25173473fb8879d111544d77af5
(cherry picked from commit 2f30f44406)
This commit is contained in:
elajkat 2024-06-06 12:34:03 +02:00 committed by Lajos Katona
parent 02c2471234
commit 5c8aea475a
3 changed files with 6 additions and 0 deletions

View File

@ -1617,6 +1617,8 @@ class OFPPropBase(StringifyMixin):
@classmethod
def parse(cls, buf):
(type_, length) = struct.unpack_from(cls._PACK_STR, buf, 0)
if not length:
raise ValueError
rest = buf[utils.round_up(length, 8):]
try:
subcls = cls._TYPES[type_]

View File

@ -884,6 +884,8 @@ class OFPPropBase(StringifyMixin):
@classmethod
def parse(cls, buf):
(type_, length) = struct.unpack_from(cls._PACK_STR, buf, 0)
if not length:
raise ValueError
rest = buf[utils.round_up(length, 8):]
try:
subcls = cls._TYPES[type_]

View File

@ -1027,6 +1027,8 @@ class OFPPropBase(StringifyMixin):
@classmethod
def parse(cls, buf):
(type_, length) = struct.unpack_from(cls._PACK_STR, buf, 0)
if not length:
raise ValueError
rest = buf[utils.round_up(length, 8):]
try:
subcls = cls._TYPES[type_]