bpo-34922: Fix integer overflow in the digest() and hexdigest() methods (GH-9751)

for the SHAKE algorithm in the hashlib module.
This commit is contained in:
Serhiy Storchaka 2018-10-11 07:41:00 +03:00 committed by GitHub
parent f1aa8aed4a
commit 9b8c2e7676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -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.
*/