From 9b8c2e767643256202bb11456ba8665593b9a500 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 11 Oct 2018 07:41:00 +0300 Subject: bpo-34922: Fix integer overflow in the digest() and hexdigest() methods (GH-9751) for the SHAKE algorithm in the hashlib module. --- Modules/_sha3/sha3module.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Modules/_sha3/sha3module.c') diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index 46c1ff1538..b737363d71 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. */ -- cgit v1.2.1