summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuka Perkov <luka@openwrt.org>2015-04-11 23:43:03 +0200
committerJohn Crispin <blogic@openwrt.org>2015-04-12 21:21:34 +0200
commita4ca61527236e89eb9efb782fd9bfd04796144e3 (patch)
tree05ffa796c1f2a479218bd139e39ca550030cceeb
parentdb1c50c090bad72eb5c28b1867b7564708ba7f3c (diff)
downloadustream-ssl-a4ca61527236e89eb9efb782fd9bfd04796144e3.tar.gz
polarssl: fix long writes
Enable to write more data then defined in SSL_MAX_CONTENT_LEN. Signed-off-by: Luka Perkov <luka@openwrt.org>
-rw-r--r--ustream-polarssl.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/ustream-polarssl.c b/ustream-polarssl.c
index cbf24cb..615ac2d 100644
--- a/ustream-polarssl.c
+++ b/ustream-polarssl.c
@@ -232,17 +232,23 @@ __hidden enum ssl_conn_status __ustream_ssl_connect(struct ustream_ssl *us)
__hidden int __ustream_ssl_write(struct ustream_ssl *us, const char *buf, int len)
{
void *ssl = us->ssl;
- int ret = ssl_write(ssl, (const unsigned char *) buf, len);
+ int done = 0, ret = 0;
- if (ret < 0) {
- if (ssl_do_wait(ret))
- return 0;
+ while (done != len) {
+ ret = ssl_write(ssl, (const unsigned char *) buf + done, len - done);
- ustream_ssl_error(us, ret);
- return -1;
+ if (ret < 0) {
+ if (ssl_do_wait(ret))
+ return done;
+
+ ustream_ssl_error(us, ret);
+ return -1;
+ }
+
+ done += ret;
}
- return ret;
+ return done;
}
__hidden int __ustream_ssl_read(struct ustream_ssl *us, char *buf, int len)