From a1efe959caf6703851b1b941b9a310cdbd38dde0 Mon Sep 17 00:00:00 2001 From: Carlo Pires Date: Mon, 13 Feb 2012 17:43:16 -0200 Subject: [PATCH] Fix ssl_send to send data in chunks of SSL_MAX_CONTENT_LEN --- src/io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/io.c b/src/io.c index dc4fe0f2..66df3647 100644 --- a/src/io.c +++ b/src/io.c @@ -142,12 +142,20 @@ static int ssl_do_handshake(IOBuf *iob) static ssize_t ssl_send(IOBuf *iob, char *buffer, int len) { + ssize_t sent = 0; + check(iob->use_ssl, "IOBuf not set up to use ssl"); if(!iob->handshake_performed) { int rcode = ssl_do_handshake(iob); check(rcode == 0, "handshake failed"); } - return ssl_write(&iob->ssl, (const unsigned char*) buffer, len); + + do { + // must send in chunks of SSL_MAX_CONTENT_LEN + sent += ssl_write(&iob->ssl, (const unsigned char*) (buffer + sent), (len - sent)); + } while (sent < len); + + return sent; error: return -1; }