From 07f0cba77a67d6559003c3262b5c05d7456a37aa Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Aug 14 2019 09:20:00 +0000 Subject: use right top limit randint's top limit is included in range, so original value 256 can be reached and as such hex-digit 100 is emitted enlarging the string. Fixes: https://pagure.io/koji/issue/1611 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 34bd435..6ba337b 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5560,7 +5560,7 @@ def generate_token(nbytes=32): if secrets: return secrets.token_hex(nbytes=nbytes) else: - values = ['%02x' % random.randint(0, 256) for x in range(nbytes)] + values = ['%02x' % random.randint(0, 255) for x in range(nbytes)] return ''.join(values)