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>
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);