Skip to content

Commit

Permalink
Fix ssl_send to send data in chunks of SSL_MAX_CONTENT_LEN
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopires committed Feb 13, 2012
1 parent b6d24f8 commit a1efe95
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/io.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit a1efe95

Please sign in to comment.