bpo-34922: Fix integer overflow in the digest() and hexdigest() methods (GH-9751)
for the SHAKE algorithm in the hashlib module.
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 @@
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.
*/