From 9fd86dfe8c338e527f616db077d93f07517c3f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E6=98=80=E8=8F=B2?= Date: Mon, 21 Jul 2025 11:52:33 +0800 Subject: [PATCH] underflow and allow some space bufi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 汪昀菲 --- lib/misc/lecp.c | 3 ++- lib/roles/cgi/cgi-server.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/misc/lecp.c b/lib/misc/lecp.c index 4783241a..d55b15c3 100644 --- a/lib/misc/lecp.c +++ b/lib/misc/lecp.c @@ -524,7 +524,8 @@ i2: goto reject_callback; pst->ppos = st->p; ctx->path[pst->ppos] = '\0'; - ctx->ipos--; + if (ctx->ipos) + ctx->ipos--; lecp_check_path_match(ctx); lwcp_completed(ctx, 0); break; diff --git a/lib/roles/cgi/cgi-server.c b/lib/roles/cgi/cgi-server.c index a6f04fa1..34015e1e 100644 --- a/lib/roles/cgi/cgi-server.c +++ b/lib/roles/cgi/cgi-server.c @@ -828,7 +828,7 @@ agin: n = lws_get_socket_fd(wsi->http.cgi->lsp->stdwsi[LWS_STDOUT]); if (n < 0) return -1; - n = (int)read(n, start, sizeof(buf) - LWS_PRE); + n = (int)read(n, start, sizeof(buf) - LWS_PRE - 16); if (n < 0 && errno != EAGAIN) { lwsl_wsi_debug(wsi, "stdout read says %d", n); -- Gitee