From 7ee8627f6eb7cf63b34d2701d76bb66f6db811e5 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 7 Sep 2016 11:34:39 +0100 Subject: Convert libssl writing for size_t Reviewed-by: Rich Salz --- ssl/s3_enc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ssl/s3_enc.c') 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) -- cgit v1.2.3