summaryrefslogtreecommitdiffstats
path: root/ssl/s3_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssl/s3_enc.c')
-rw-r--r--ssl/s3_enc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 56bd34a3d1..f32b68a0b3 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -356,13 +356,18 @@ void ssl3_free_digest_list(SSL *s)
s->s3->handshake_dgst = NULL;
}
-int ssl3_finish_mac(SSL *s, const unsigned char *buf, int len)
+int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len)
{
- if (s->s3->handshake_dgst == NULL)
+ if (s->s3->handshake_dgst == NULL) {
+ int ret;
/* Note: this writes to a memory BIO so a failure is a fatal error */
- return BIO_write(s->s3->handshake_buffer, (void *)buf, len) == len;
- else
+ if (len > INT_MAX)
+ return 0;
+ ret = BIO_write(s->s3->handshake_buffer, (void *)buf, (int)len);
+ return ret > 0 && ret == (int)len;
+ } else {
return EVP_DigestUpdate(s->s3->handshake_dgst, buf, len);
+ }
}
int ssl3_digest_cached_records(SSL *s, int keep)