http: body length is the remaining buffer, not Content-Length (breaks pipelining and corrupts bodies)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 69/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- backend, networking
Direzione di ricerca
Start in lib/monkey/mk_server/mk_http_parser.c at the header_content_length body handling described in the issue, then inspect how src/http_server/flb_http_server_http1.c copies the parsed body. Check for existing parser tests covering body lengths and buffered follow-up bytes. Done means the parsed body ends at Content-Length and remaining buffered bytes can be processed as the next request without corrupting the body.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Describe the bug
The HTTP parser sets the request body length to everything remaining in the buffer instead of to
Content-Length. Any bytes buffered after the declared body — a pipelined request, or just extra data — become
part of the body. Depending on the content type this either corrupts the payload or breaks the request outright,
and the pipelined request is then never processed.
To Reproduce
One connection, Content-Type: application/json, Content-Length: 7, body {"a":1}, followed immediately by
three extra bytes:
POST / HTTP/1.1
Host: x
Content-Type: application/json
Content-Length: 7
{"a":1}ZZZ
Result: 400 Bad Request, and the log says invalid JSON message, skipping — the body handed to the JSON
parser was {"a":1}ZZZ, not {"a":1}.
With Content-Type: application/x-www-form-urlencoded the same trailing bytes are silently absorbed into the
last field instead (that is issue #12650, which is a symptom of this), and a pipelined request is swallowed
entirely.
Root cause
lib/monkey/mk_server/mk_http_parser.c:
if (p->header_content_length > 0) {
p->body_received = len - p->start; /* everything left in the buffer */
if ((len - p->start) < p->header_content_length) {
return MK_HTTP_PARSER_PENDING;
}
/* Cut off */
p->i += p->body_received;
req->data.len = p->body_received; /* so the body is too long */
req->data.data = (buffer + p->start);
}
len is buf_len. body_received should be p->header_content_length; the check above it only uses
len - p->start to decide whether enough data has arrived.
src/http_server/flb_http_server_http1.c then copies inner_request.data.len bytes straight into the request
body, so the over-long length propagates.
Expected behavior
req->data.len should be p->header_content_length, and p->i should advance by that amount so the remaining
bytes stay buffered for the next request.
Your Environment
- Fluent Bit 5.1.5 (
fluent/fluent-bit:latest); identical on currentmaster - Linux, aarch64, official container image
- Input:
httpplugin, default settings
Impact
Pre-auth. Content-Length is effectively ignored for framing: any request that shares a buffer with following
bytes gets a corrupted body, and pipelined requests are lost. For JSON it is an outright 400; for urlencoded it
is silent record corruption. It is also the root cause of #12650.
- Lingua principale
- C
- Stelle
- 8.2k
- Fork
- 2k
- Merge medio
- 3g 20h
- PR unite (30g)
- 99
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fluent/fluent-bit
-
in_tail: files falsely detected as rotated on macOS with threaded inputs, causing duplicate recordsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
fluent/fluent-bit#12780 ·
I maintainer di solito rispondono entro 1 giorno
-
status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fluent/fluent-bit#12683 · 2 commenti · 6 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
fluent/fluent-bit#12657 ·
I maintainer di solito rispondono entro 1 giorno
-
http: Transfer-Encoding chunked plus Content-Length hangs forever (CL branch shadows the chunked path)Forse già presa @sarankumar1325 l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
fluent/fluent-bit#12656 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
fluent/fluent-bit#12649 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di fluent/fluent-bit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
micropython/micropython#19942 ·
I maintainer di solito rispondono entro 1 giorno
-
快速入门那里会不会对新手不太友好,提出优化方案Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
-disable-symbolserver is ignored on macOS/Linux: PDBs are still downloaded from msdl.microsoft.comAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
-
follow-up Prio 📌
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno