From 7e4c67e29d623cd5a5d9d1a6731b6ef67d9f97c2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 5 Nov 2017 16:31:14 +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 61975c97..c7d9d8e3 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.