polarssl: fix long writes
authorLuka Perkov <luka@openwrt.org>
Sat, 11 Apr 2015 21:43:03 +0000 (23:43 +0200)
committerJohn Crispin <blogic@openwrt.org>
Sun, 12 Apr 2015 19:21:34 +0000 (21:21 +0200)
Enable to write more data then defined in SSL_MAX_CONTENT_LEN.

Signed-off-by: Luka Perkov <luka@openwrt.org>
ustream-polarssl.c

index cbf24cb44d9b4a504b4d0798963b60270ad7adf2..615ac2d88bff5ce09b5dbe00eb6815ed949dfc42 100644 (file)
@@ -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)