A single SSL record can't contain >16KiB, so the HTTPS request buffer may not get fully written if it's larger than this. I discovered this frustrating bug while working on GlobalProtect HIP support, which requires sending giant blobs of XML to the gateway. Signed-off-by: Daniel Lenski <dlenski at gmail.com> --- http.c | 6 +++++- openconnect-internal.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/http.c b/http.c index 812e002..b6908c0 100644 --- a/http.c +++ b/http.c @@ -913,7 +913,11 @@ int do_https_request(struct openconnect_info *vpninfo, const char *method, if (vpninfo->dump_http_traffic) dump_buf(vpninfo, '>', buf->data); - result = vpninfo->ssl_write(vpninfo, buf->data, buf->pos); + for (int i=result=0; i<=buf->pos; i+=16384) { + result = vpninfo->ssl_write(vpninfo, buf->data+i, MIN(buf->pos-i, 16384) ); + if (result<0) + break; + } if (rq_retry && result < 0) { openconnect_close_https(vpninfo, 0); goto retry; diff --git a/openconnect-internal.h b/openconnect-internal.h index 923d5a1..02716fd 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -122,6 +122,9 @@ #ifndef MAX #define MAX(x,y) ((x)>(y))?(x):(y) #endif +#ifndef MIN +#define MIN(x,y) ((x)<(y))?(x):(y) +#endif /****************************************************************************/ struct pkt { -- 2.7.4