Skip to content

Commit

Permalink
fix: bytearray may be passed into lru_cached func
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Sep 7, 2022
1 parent bad06ab commit caa0223
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions socksio/socks4.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def loads(cls, data: bytes) -> "SOCKS4Reply":
Raises:
ProtocolError: If the data does not match the spec.
"""
if isinstance(data, bytearray):
data = bytes(data)

if len(data) != 8 or data[0:1] != b"\x00":
raise ProtocolError("Malformed reply")

Expand Down
3 changes: 3 additions & 0 deletions socksio/socks5.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ def loads(cls, data: bytes) -> "SOCKS5Reply":
Raises:
ProtocolError: If the data does not match the spec.
"""
if isinstance(data, bytearray):
data = bytes(data)

if data[0:1] != b"\x05":
raise ProtocolError("Malformed reply")

Expand Down

0 comments on commit caa0223

Please sign in to comment.