commit 3d3e68c05fbe84f7cf0eff45e376480ec50b48c3 Author: Dave Rolek dmr-x@riseup.net Date: Sun Jun 3 19:32:57 2018 +0000
Remove redundant content-length checks
The Size pop calls() following where the respective checks were will raise an exception if the content isn't large enough for that Size.
Additionally, for the NetinfoCell payload unpacking, the removed check exception was actually unreachable unless NetinfoCell._unpack() were called directly, instead of through Cell.pop(), since it is a fixed-sized cell. --- stem/client/cell.py | 3 --- stem/client/datatype.py | 5 ----- 2 files changed, 8 deletions(-)
diff --git a/stem/client/cell.py b/stem/client/cell.py index 57ccc1ab..0f9ae59e 100644 --- a/stem/client/cell.py +++ b/stem/client/cell.py @@ -555,9 +555,6 @@ class NetinfoCell(Cell):
@classmethod def _unpack(cls, content, circ_id, link_protocol): - if len(content) < Size.LONG.size: - raise ValueError('NETINFO cell expected to start with a timestamp') - timestamp, content = Size.LONG.pop(content) receiver_address, content = Address.pop(content)
diff --git a/stem/client/datatype.py b/stem/client/datatype.py index db9d461a..2ee624cb 100644 --- a/stem/client/datatype.py +++ b/stem/client/datatype.py @@ -420,11 +420,6 @@ class Address(Field):
@staticmethod def pop(content): - if not content: - raise ValueError('Payload empty where an address was expected') - elif len(content) < 2: - raise ValueError('Insuffient data for address headers') - addr_type, content = Size.CHAR.pop(content) addr_length, content = Size.CHAR.pop(content)
tor-commits@lists.torproject.org