From: Jo-Philipp Wich Date: Sun, 30 Oct 2022 23:53:29 +0000 (+0100) Subject: client: fix incorrectly emitting HTTP 413 for certain content lengths X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=23977554d9694d025eada50a5547e99ee1be7838;p=project%2Fuhttpd.git client: fix incorrectly emitting HTTP 413 for certain content lengths The existing logic for checking overlong request headers did not take into account that when the request body content length is a multiple of 4096, the request handling state might transition directly from CLIENT_STATE_HEADER or CLIENT_STATE_DATA to CLIENT_STATE_DONE, in which case we must not emit a stray HTTP 413 error. Fixes: https://github.com/openwrt/luci/issues/2051 Signed-off-by: Liangbin Lian [Change commit subject, add commit message, swap order of conditions] Signed-off-by: Jo-Philipp Wich --- diff --git a/client.c b/client.c index 06336eb..c037cc7 100644 --- a/client.c +++ b/client.c @@ -532,7 +532,8 @@ void uh_client_read_cb(struct client *cl) if (!read_cbs[cl->state](cl, str, len)) { if (len == us->r.buffer_len && - cl->state != CLIENT_STATE_DATA) + cl->state != CLIENT_STATE_DATA && + cl->state != CLIENT_STATE_DONE) uh_header_error(cl, 413, "Request Entity Too Large"); break; }