From baef7fdac28e4e1fe26509b50b8d15603393e28e Mon Sep 17 00:00:00 2001
From: Sergey Kandaurov <pluknet@nginx.com>
Date: Wed, 29 Apr 2026 21:56:51 +0400
Subject: [PATCH] Upstream: reset parsing state after invalid status line

Previously, it was possible to start parsing headers with a wrong
parsing state after status line was not recognized, as a fallback
used in the scgi and uwsgi modules.

Reported by Leo Lin.
---
 src/http/modules/ngx_http_scgi_module.c  | 1 +
 src/http/modules/ngx_http_uwsgi_module.c | 1 +
 2 files changed, 2 insertions(+)

--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -984,6 +984,7 @@ ngx_http_scgi_process_status_line(ngx_ht
 
     if (rc == NGX_ERROR) {
         u->process_header = ngx_http_scgi_process_header;
+        r->state = 0;
         return ngx_http_scgi_process_header(r);
     }
 
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -1194,6 +1194,7 @@ ngx_http_uwsgi_process_status_line(ngx_h
 
     if (rc == NGX_ERROR) {
         u->process_header = ngx_http_uwsgi_process_header;
+        r->state = 0;
         return ngx_http_uwsgi_process_header(r);
     }
 
