Merge "Raise ValueError in case unpack_from returns zero length" into unmaintained/victoria

This commit is contained in:
Zuul 2024-07-03 12:41:00 +00:00 committed by Gerrit Code Review
commit 6079795b01
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_]