From 050076e2b4a5cd7cb701a97b6b85c51b99382910 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=B5=9C=EB=8C=80=EC=9A=B0=20=28Daewoo=20Choi=29?= Date: Mon, 2 Nov 2026 13:07:30 +0900 Subject: [PATCH] Control API: fixed handling of oversized requests A request line larger than the receive buffer was answered with no response at all, while every other malformed request gets a status code. The buffer-full check also ran at the start of the next read event, which may never arrive, since SIGIO is raised by new data. The check is now made after parsing, so 400 is returned right away. --- src/os/unix/ngx_control.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/os/unix/ngx_control.c b/src/os/unix/ngx_control.c index 2877b6a65..bfe508948 100644 --- a/src/os/unix/ngx_control.c +++ b/src/os/unix/ngx_control.c @@ -567,12 +567,6 @@ ngx_control_handle_read(ngx_control_request_t *r) b = r->in; - if (b->last == b->end) { - ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, - "control: request too large"); - return NGX_ERROR; - } - n = recv(r->fd, b->last, b->end - b->last, 0); if (n < 0) { @@ -594,6 +588,13 @@ ngx_control_handle_read(ngx_control_request_t *r) switch (ngx_control_parse_request_line(r)) { case NGX_AGAIN: + if (b->last == b->end) { + ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, + "control: request too large"); + ngx_control_pollfd[r->index].events &= ~POLLIN; + return ngx_control_send_response(r, NGX_CTRL_BAD_REQUEST, NULL); + } + return NGX_AGAIN; case NGX_DECLINED: -- 2.47.3