Raise ValueError in case unpack_from returns zero length

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 35df49c4ac
commit e80f7cdf83
3 changed files with 12 additions and 0 deletions

View File

@@ -1618,6 +1618,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_]
@@ -6592,6 +6594,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

@@ -902,6 +902,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_]
@@ -5950,6 +5952,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

@@ -1045,6 +1045,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_]
@@ -7051,6 +7053,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_]