Raise ValueError in case unpack_from returns zero length

Closes-Bug: #2067973
Closes-Bug: #2067970
Change-Id: If3327be6c0a4c25173473fb8879d111544d77af5
This commit is contained in:
elajkat 2024-06-06 12:34:03 +02:00 committed by Brian Haley
parent 2efd73e4db
commit 2f30f44406
3 changed files with 12 additions and 0 deletions

View File

@ -1616,6 +1616,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_]
@ -6602,6 +6604,8 @@ class NXTPacketIn2Prop(OFPPropBase):
@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

@ -900,6 +900,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_]
@ -5948,6 +5950,8 @@ class NXTPacketIn2Prop(OFPPropBase):
@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

@ -1043,6 +1043,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_]
@ -7049,6 +7051,8 @@ class NXTPacketIn2Prop(OFPPropBase):
@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_]