From 577fa446914bd140d080005c3d5ab5fb97552f56 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 12 Jun 2025 17:39:31 +0200 Subject: [PATCH] BUG/MINOR: quic: work around NEW_TOKEN parsing error on backend side NEW_TOKEN frame is never emitted by a client, hence parsing was not tested on frontend side. On backend side, an issue can occur, as expected token length is static, based on the token length used internally by haproxy. This is not sufficient for most server implementation which uses larger token. This causes a parsing error, which may cause skipping of following frames in the same packet. This issue was detected using ngtcp2 as server. As for now tokens are unused by haproxy, simply discard test on token length during NEW_TOKEN frame parsing. The token itself is merely skipped without being stored. This is sufficient for now to continue on experimenting with QUIC backend implementation. This does not need to be backported. --- src/quic_frame.c | 12 ++++++++++-- src/quic_rx.c | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/quic_frame.c b/src/quic_frame.c index d7a081e1a..7e1dbba54 100644 --- a/src/quic_frame.c +++ b/src/quic_frame.c @@ -500,11 +500,19 @@ static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn * { struct qf_new_token *new_token_frm = &frm->new_token; - if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len || - sizeof(new_token_frm->data) < new_token_frm->len) + if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len) return 0; + /* TODO token length is unknown as it is dependent from the peer. Hence + * dynamic allocation should be implemented for token storage, albeit + * with constraint to ensure memory usage remains reasonable. + */ +#if 0 + if (sizeof(new_token_frm->data) < new_token_frm->len) + return 0; memcpy(new_token_frm->data, *pos, new_token_frm->len); +#endif + *pos += new_token_frm->len; return 1; diff --git a/src/quic_rx.c b/src/quic_rx.c index b705d414d..e659bef9e 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -949,7 +949,11 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt, goto err; } else { - /* TODO */ + /* TODO NEW_TOKEN not implemented on client side. + * Note that for now token is not copied into field + * of qf_new_token frame. See quic_parse_new_token_frame() + * for further explanations. + */ } break; case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F: