From c21fd219f3eaad12032db942c549c5bb43bea187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 20 Jun 2024 15:39:46 +0200 Subject: [PATCH] q-dev: fix hex characters validation Using "i" as a loop iterator conflicts with the outer loop, effectively turning it into infinite loop. Use a generator instead. --- qubesusbproxy/core3ext.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qubesusbproxy/core3ext.py b/qubesusbproxy/core3ext.py index 96eb5e6..ae8fd8a 100644 --- a/qubesusbproxy/core3ext.py +++ b/qubesusbproxy/core3ext.py @@ -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: