From 5079b96801d926b1cdeabaf0de47bf19387bb72f Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Tue, 12 Nov 2019 14:37:24 -0500
Subject: [PATCH] Limit the limit we will consider

Thanks, Hypothesis.
---
 src/_zkapauthorizer/resource.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/_zkapauthorizer/resource.py b/src/_zkapauthorizer/resource.py
index faad423..9d13a02 100644
--- a/src/_zkapauthorizer/resource.py
+++ b/src/_zkapauthorizer/resource.py
@@ -20,6 +20,9 @@ vouchers for fresh tokens.
 In the future it should also allow users to read statistics about token usage.
 """
 
+from sys import (
+    maxint,
+)
 from itertools import (
     islice,
 )
@@ -139,7 +142,7 @@ class _UnblindedTokenCollection(Resource):
 
         limit = request.args.get(b"limit", [None])[0]
         if limit is not None:
-            limit = int(limit)
+            limit = min(maxint, int(limit))
 
         position = request.args.get(b"position", [b""])[0].decode("utf-8")
 
-- 
GitLab