The vulnerability exists in the MdCtxRef::digest_final function in openssl/src/md_ctx.rs. The function takes a mutable slice out as an argument to store the digest. The underlying call to OpenSSL's EVP_DigestFinal writes a fixed number of bytes equal to the digest size. The vulnerability occurs because, prior to the patch, there was no check to ensure that the provided out slice was large enough to hold the entire digest. This could lead to a buffer overflow on the stack. The provided commit 826c3888b77add418b394770e2b2e3a72d9f92fe introduces a check if self.size() > len as usize to validate the buffer size before calling EVP_DigestFinal, thus mitigating the vulnerability. The added test case digest_final_checks_length further confirms this by asserting that an error is returned when a buffer of insufficient size is provided.