summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-06-26 08:35:06 +0200
committerJo-Philipp Wich <jo@mein.io>2018-06-26 12:40:07 +0200
commit796d42bceed2015bb00309a3bf0f49279b070c19 (patch)
tree7fb1af7e4a62e22009326424f4d93f085a85b462
parent393b59ef5d1d05fd00e102231e689f646c438582 (diff)
downloaduhttpd2-796d42bceed2015bb00309a3bf0f49279b070c19.tar.gz
client: flush buffered SSL output when tearing down client ustream
When the outer SSL ustream triggers a change notification due to encountering EOF, the inner connection ustream might still have pending data buffered. Previously, such a condition led to truncated files delivered by uhttpd via HTTPS and could be triggered by requesting large resources via slow network links. Mitigate the problem by propagating the EOF status indicator from the outer ustream to the inner one and by deferring the client connection shutdown until the inner ustream output buffer has been completely drained. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--client.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/client.c b/client.c
index 05044ed..04d26f1 100644
--- a/client.c
+++ b/client.c
@@ -553,6 +553,12 @@ void uh_client_notify_state(struct client *cl)
if (!s->eof || s->w.data_bytes)
return;
+
+ if (cl->tls && cl->ssl.conn && cl->ssl.conn->w.data_bytes) {
+ cl->ssl.conn->eof = s->eof;
+ if (!ustream_write_pending(cl->ssl.conn))
+ return;
+ }
}
return client_close(cl);