Author: Ronan Lamy <[email protected]>
Branch: py3.6
Changeset: r97233:4239b16d9453
Date: 2019-08-21 17:21 +0100
http://bitbucket.org/pypy/pypy/changeset/4239b16d9453/

Log:    Prevent overflow in digest() (bpo-34922)

diff --git a/lib_pypy/_sha3/__init__.py b/lib_pypy/_sha3/__init__.py
--- a/lib_pypy/_sha3/__init__.py
+++ b/lib_pypy/_sha3/__init__.py
@@ -64,6 +64,8 @@
 
 class _shake(_sha3):
     def digest(self, length):
+        if length >= (1 << 29):
+            raise ValueError("length is too large")
         # ExtractLane needs at least SHA3_MAX_DIGESTSIZE + SHA3_LANESIZE and
         # SHA_LANESIZE extra space.
         digest = _ffi.new("char[]", length + SHA3_LANESIZE)
@@ -79,7 +81,7 @@
 
     def hexdigest(self, length):
         return codecs.encode(self.digest(length), 'hex').decode()
-        
+
 
 class sha3_224(_sha3):
     name = "sha3_224"
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to