Add sanity check to PRF

The function tls1_PRF counts the number of digests in use and partitions
security evenly between them. There always needs to be at least one digest
in use, otherwise this is an internal error. Add a sanity check for this.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 668f6f08c6)
This commit is contained in:
Matt Caswell 2015-03-12 14:37:26 +00:00
parent b2b8163964
commit fcb61b6c92

View file

@ -260,6 +260,11 @@ static int tls1_PRF(long digest_mask,
if ((m << TLS1_PRF_DGST_SHIFT) & digest_mask) if ((m << TLS1_PRF_DGST_SHIFT) & digest_mask)
count++; count++;
} }
if(!count) {
/* Should never happen */
SSLerr(SSL_F_TLS1_PRF, ERR_R_INTERNAL_ERROR);
goto err;
}
len = slen / count; len = slen / count;
if (count == 1) if (count == 1)
slen = 0; slen = 0;