summaryrefslogtreecommitdiffstats
path: root/Modules/_sha3
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-10-11 04:41:00 (GMT)
committerGitHub <noreply@github.com>2018-10-11 04:41:00 (GMT)
commit9b8c2e767643256202bb11456ba8665593b9a500 (patch)
tree92b674df44b5bb6d14583e910cf38f0ead9837bb /Modules/_sha3
parentf1aa8aed4a8ce9753ffa8713e7d3461663e0624d (diff)
downloadcpython-9b8c2e767643256202bb11456ba8665593b9a500.zip
cpython-9b8c2e767643256202bb11456ba8665593b9a500.tar.gz
cpython-9b8c2e767643256202bb11456ba8665593b9a500.tar.bz2
bpo-34922: Fix integer overflow in the digest() and hexdigest() methods (GH-9751)
for the SHAKE algorithm in the hashlib module.
Diffstat (limited to 'Modules/_sha3')
-rw-r--r--Modules/_sha3/sha3module.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index 46c1ff1..b737363 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -589,6 +589,10 @@ _SHAKE_digest(SHA3object *self, unsigned long digestlen, int hex)
int res;
PyObject *result = NULL;
+ if (digestlen >= (1 << 29)) {
+ PyErr_SetString(PyExc_ValueError, "length is too large");
+ return NULL;
+ }
/* ExtractLane needs at least SHA3_MAX_DIGESTSIZE + SHA3_LANESIZE and
* SHA3_LANESIZE extra space.
*/