Add sanity check to PRF
authorMatt Caswell <matt@openssl.org>
Thu, 12 Mar 2015 14:37:26 +0000 (14:37 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 17 Mar 2015 13:49:32 +0000 (13:49 +0000)
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 668f6f08c62177ab5893fc26ebb67053aafdffc8)

ssl/t1_enc.c

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