Bare carriage returns in header line endings are still forwarded when separated from the CRLF by whitespace
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- networking
Direzione di ricerca
Inizia in mime_parser_parse e verifica la gestione di raw-print descritta nell’issue, quindi esegui test_proxy_hdrs. Controlla i casi request e parse_resp per i cinque terminatori di riga malformati, confermando al contempo che i campi ben formati e ripiegati mantengano un output byte per byte. Usa tests/gold_tests/headers/field_name_space.test.py come riferimento end-to-end per il comportamento a livello wire.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Follow-up to #12195 and #13595.
#13595 stops the raw input line from being preserved when the byte immediately before the terminating CRLF is a carriage return. That covers the line reported in #12195, but not the general case.
mime_parser_parse trims the field value with field_value.rtrim_if(&ParseRules::is_wslfcr), which strips SP and HT as well as CR and LF. So a bare CR only has to be separated from the CRLF by one space or tab to end up back in the raw-print pad and be forwarded unchanged.
Built on master with #13595 applied, output captured from HTTPHdr::print:
| request header line | serialized output |
|---|---|
Extra-CRs: \r\r\r\r\n |
Extra-CRs: \r\n (fixed by #13595) |
Extra-CRs: \r \r\n |
Extra-CRs: \r \r\n |
Extra-CRs: \r\r \r\n |
Extra-CRs: \r\r \r\n |
Extra-CRs: bar\r \r\n |
Extra-CRs: bar\r \r\n |
Extra-CRs: \r\t\r\n |
Extra-CRs: \r\t\r\n |
RFC 9112 section 2.2 says a recipient of a bare CR must either consider the element invalid or replace each bare CR with SP before processing or forwarding the message. The last four rows do neither.
A positional check will keep missing spellings of this. Making it structural works and keeps the fast path: once the value is trimmed, require that everything between the end of the value and the end of the line is optional whitespace followed by exactly one CRLF.
// find value first
field_value.ltrim_if(&ParseRules::is_ws);
field_value.rtrim_if(&ParseRules::is_wslfcr);
if (raw_print_field) {
// Raw printing copies the original input bytes instead of re-serializing, so it would
// replay this line ending verbatim. Everything between the end of the trimmed value and
// the end of the line must be optional whitespace followed by exactly one CRLF; a bare
// CR in there is malformed (RFC 9112 section 2.2) and must not be forwarded.
TextView tail{field_value.data() + field_value.size(), parsed.data() + parsed.size()};
if (tail.suffix(2) != "\r\n" || tail.remove_suffix(2).find_first_of("\r\n") != TextView::npos) {
raw_print_field = false;
}
}
With that in place all five rows normalize to a single CRLF and test_proxy_hdrs stays green. Well-formed fields keep the raw fast path: X: a \r\n, X:\ta\r\n and a folded line are all still emitted byte for byte. The else if on the line ending goes away, as does the need for the size() > 2 guard, since suffix() clamps.
Three smaller items for the same change:
- The unit test fixture added in #13595 produces a raw-print pad of exactly 7, and
mime_field_name_value_setonly honors raw printing when the pad is 7 or less. One more CR and the pre-existing pad gate suppresses raw printing on its own, so the test would pass without any fix at all. It needs a comment saying so, plus a case that is not on the boundary. - Only the request direction is covered. The same function serves responses, so a
parse_respcase is cheap. tests/gold_tests/headers/field_name_space.test.pycovers the sibling whitespace-before-colon case end to end. BecauseMIMEFieldBlockImpl::move_stringsclears the raw flag on any string-heap relocation, whether these bytes reach the origin depends on heap state a unit test does not exercise, so a gold test with a raw-socket client would pin the actual wire contract.
This reproduces on 10.2.x and 10.1.x as well.
- Lingua principale
- C++
- Stelle
- 2k
- Fork
- 878
- Merge medio
- 3g 16h
- PR unite (30g)
- 91
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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 apache/trafficserver
-
Bug HTTP Support
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
apache/trafficserver#13118 ·
I maintainer di solito rispondono entro 2 giorni
-
header_rewrite: rm-destination after set-destination URL crashes traffic_serverForse già presa @moonchen l’ha presa 4 giorni fa. ApertaBug Crash header_rewrite Plugins
apache/trafficserver#13800 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
apache/trafficserver#13798 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
apache/trafficserver#13784 ·
I maintainer di solito rispondono entro 2 giorni
-
Plugins
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
apache/trafficserver#13774 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/trafficserver
Issue simili
-
[request] vsg/1.1.16Apertaupstream update
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
conan-io/conan-center-index#31142 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
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 84/100
NVIDIA/DeepStream#78 ·