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:
@@ -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_]
|
||||
|
@@ -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_]
|
||||
|
@@ -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_]
|
||||
|
Reference in New Issue
Block a user