From 8dcb4ca753efe08adfd94ce0348bde2f01a53cb4 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 5 Nov 2017 19:40:34 +0800 Subject: [PATCH] h2: never send more than file length --- lib/output.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/output.c b/lib/output.c index ed4752490..c8b05cb9e 100644 --- a/lib/output.c +++ b/lib/output.c @@ -507,7 +507,7 @@ send_raw: (wp & 0x1f) == LWS_WRITE_HTTP_FINAL) && wsi->u.http.tx_content_length) { wsi->u.http.tx_content_remain -= len; - lwsl_info("%s: content_remain = %llu\n", __func__, + lwsl_info("%s: wsi %p: tx_content_remain = %llu\n", __func__, wsi, (unsigned long long)wsi->u.http.tx_content_remain); if (!wsi->u.http.tx_content_remain) { lwsl_info("%s: selecting final write mode\n", __func__); @@ -639,6 +639,9 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws *wsi) poss = context->pt_serv_buf_size - n - LWS_H2_FRAME_HEADER_LENGTH; + if (poss > wsi->u.http.tx_content_remain) + poss = wsi->u.http.tx_content_remain; + /* * if there is a hint about how much we will do well to send at one time, * restrict ourselves to only trying to send that.