HTTP: Remove redundant state from chunk parsing

The state machine never returns with state = sw_chunk_data and a size of
zero, nor did it return with state = sw_after_data.
This commit is contained in:
Demi Marie Obenour 2025-04-07 01:25:03 -04:00
parent 626b1d9bba
commit 436282ff74

View File

@ -2292,7 +2292,6 @@ ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b,
sw_chunk_extension_unquoted_value, sw_chunk_extension_unquoted_value,
sw_chunk_extension_almost_done, sw_chunk_extension_almost_done,
sw_chunk_data, sw_chunk_data,
sw_after_data,
sw_after_data_almost_done, sw_after_data_almost_done,
sw_trailer, sw_trailer,
sw_trailer_almost_done, sw_trailer_almost_done,
@ -2303,10 +2302,6 @@ ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b,
state = ctx->state; state = ctx->state;
if (state == sw_chunk_data && ctx->size == 0) {
state = sw_after_data;
}
rc = NGX_AGAIN; rc = NGX_AGAIN;
for (pos = b->pos; pos < b->last; pos++) { for (pos = b->pos; pos < b->last; pos++) {
@ -2470,10 +2465,10 @@ before_semi:
goto invalid; goto invalid;
case sw_chunk_data: case sw_chunk_data:
rc = NGX_OK; if (ctx->size != 0) {
goto data; rc = NGX_OK;
goto data;
case sw_after_data: }
if (ch == CR) { if (ch == CR) {
state = sw_after_data_almost_done; state = sw_after_data_almost_done;
break; break;
@ -2608,9 +2603,6 @@ data:
case sw_chunk_data: case sw_chunk_data:
ctx->length = min_length; ctx->length = min_length;
break; break;
case sw_after_data:
ctx->length = 6 /* CR LF "0" CR LF LF */;
break;
case sw_after_data_almost_done: case sw_after_data_almost_done:
ctx->length = 5 /* LF "0" CR LF LF */; ctx->length = 5 /* LF "0" CR LF LF */;
break; break;