summaryrefslogtreecommitdiff
path: root/dns/tokenizer.py
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-10 18:12:44 -0700
committerBob Halley <halley@dnspython.org>2020-08-10 18:13:31 -0700
commitcef16575c31a9b0fe03f128ede23e8991cbebe77 (patch)
treefe41cf5a07303cb1f8f1727f4d50dcd745ed05e2 /dns/tokenizer.py
parent8a032fa375555b83d31df77191dd66e669421ab7 (diff)
downloaddnspython-cef16575c31a9b0fe03f128ede23e8991cbebe77.tar.gz
detect escapes > 255
Diffstat (limited to 'dns/tokenizer.py')
-rw-r--r--dns/tokenizer.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/dns/tokenizer.py b/dns/tokenizer.py
index 7d698ea..131d428 100644
--- a/dns/tokenizer.py
+++ b/dns/tokenizer.py
@@ -120,7 +120,10 @@ class Token:
i += 1
if not (c2.isdigit() and c3.isdigit()):
raise dns.exception.SyntaxError
- c = chr(int(c) * 100 + int(c2) * 10 + int(c3))
+ codepoint = int(c) * 100 + int(c2) * 10 + int(c3)
+ if codepoint > 255:
+ raise dns.exception.SyntaxError
+ c = chr(codepoint)
unescaped += c
return Token(self.ttype, unescaped)
@@ -171,7 +174,10 @@ class Token:
i += 1
if not (c2.isdigit() and c3.isdigit()):
raise dns.exception.SyntaxError
- unescaped += b'%c' % (int(c) * 100 + int(c2) * 10 + int(c3))
+ codepoint = int(c) * 100 + int(c2) * 10 + int(c3)
+ if codepoint > 255:
+ raise dns.exception.SyntaxError
+ unescaped += b'%c' % (codepoint)
else:
# Note that as mentioned above, if c is a Unicode
# code point outside of the ASCII range, then this