Skip to content

Commit

Permalink
q-dev: fix hex characters validation
Browse files Browse the repository at this point in the history
Using "i" as a loop iterator conflicts with the outer loop, effectively
turning it into infinite loop.
Use a generator instead.
  • Loading branch information
marmarek committed Jun 20, 2024
1 parent 29d32c5 commit c21fd21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions qubesusbproxy/core3ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ def _sanitize(
break
hex_code = untrusted_device_desc[i - 1: i + 1]
try:
for i in range(2):
if hex_code[i] not in b'0123456789abcdefABCDEF':
raise ValueError()
if any(h not in b'0123456789abcdefABCDEF'
for h in hex_code):
raise ValueError()
hex_value = int(hex_code, 16)
c = chr(hex_value)
except ValueError:
Expand Down

0 comments on commit c21fd21

Please sign in to comment.