Merge remote-tracking branch 'origin/pr/283'

Fixes QubesOS/qubes-issues#6290

* origin/pr/283:
  Handle UnicodeError in firewall when resolving hostname
This commit is contained in:
Marek Marczykowski-Górecki 2021-01-03 04:22:09 +01:00
commit 79bb5a8658
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -619,6 +619,9 @@ class NftablesWorker(FirewallWorker):
except socket.gaierror as e: except socket.gaierror as e:
raise RuleParseError('Failed to resolve {}: {}'.format( raise RuleParseError('Failed to resolve {}: {}'.format(
rule['dsthost'], str(e))) rule['dsthost'], str(e)))
except UnicodeError as e:
raise RuleParseError('Invalid destination {}: {}'.format(
rule['dsthost'], str(e)))
nft_rule += ' {} daddr {{ {} }}'.format(ip_match, nft_rule += ' {} daddr {{ {} }}'.format(ip_match,
', '.join(set(item[4][0] + fullmask for item in addrinfo))) ', '.join(set(item[4][0] + fullmask for item in addrinfo)))