summaryrefslogtreecommitdiff
path: root/dns
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2021-11-16 07:17:02 -0800
committerBob Halley <halley@dnspython.org>2021-11-16 07:17:02 -0800
commite35de75ae3df365055f62f787b3cbe4ba25364cc (patch)
tree0e2ee43a72922a81b19f71b0583b368f8f9353f0 /dns
parent3d51bf062fc4ef245abc066dead6d3ec0f976459 (diff)
downloaddnspython-e35de75ae3df365055f62f787b3cbe4ba25364cc.tar.gz
Do not impose 2**31-1 bounds on TTL-like things; impose 2**32-1.
Diffstat (limited to 'dns')
-rw-r--r--dns/ttl.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/dns/ttl.py b/dns/ttl.py
index 8ea5213..df92b2b 100644
--- a/dns/ttl.py
+++ b/dns/ttl.py
@@ -19,7 +19,13 @@
import dns.exception
-MAX_TTL = 2147483647
+# Technically TTLs are supposed to be between 0 and 2**31 - 1, with values
+# greater than that interpreted as 0, but we do not impose this policy here
+# as values > 2**31 - 1 occur in real world data.
+#
+# We leave it to applications to impose tighter bounds if desired.
+MAX_TTL = 2**32 - 1
+
class BadTTL(dns.exception.SyntaxError):
"""DNS TTL value is not well-formed."""
@@ -71,7 +77,7 @@ def from_text(text):
if not current == 0:
raise BadTTL("trailing integer")
if total < 0 or total > MAX_TTL:
- raise BadTTL("TTL should be between 0 and 2^31 - 1 (inclusive)")
+ raise BadTTL("TTL should be between 0 and 2**32 - 1 (inclusive)")
return total