fix: correct 0-RTT transport param validation guard and test mock#827
Open
cherylsy wants to merge 3 commits into
Open
fix: correct 0-RTT transport param validation guard and test mock#827cherylsy wants to merge 3 commits into
cherylsy wants to merge 3 commits into
Conversation
cherylsy
force-pushed
the
fix-0rtt-param-validation-guard
branch
from
June 25, 2026 12:29
3dd44d8 to
7f11199
Compare
…irect unit testing Extract the 8 parameter comparisons (RFC 9000 §7.4.1 + RFC 9221 max_datagram_frame_size) from the inline block inside xqc_conn_tls_transport_params_cb into a standalone function xqc_conn_validate_0rtt_transport_params(). This allows unit tests to exercise the validation logic directly without TLS state mocking, CID setup, or encode/decode round-trips. Rewrite the three 0-RTT param validation tests to call the new function directly, removing the production-code invasion (early_data_accepted_override in xqc_tls_t) that the previous approach required. Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
cherylsy
force-pushed
the
fix-0rtt-param-validation-guard
branch
from
June 26, 2026 08:31
7f11199 to
107eab1
Compare
… TLS certs The test dereferences engine/conn pointers without NULL checks. When server.key / server.crt are absent from CWD, xqc_engine_create returns NULL and the subsequent xqc_engine_packet_process(NULL, ...) triggers SIGSEGV, killing the entire test process and preventing later tests (including the 0-RTT param validation suite) from running. Changes: - Add NULL guards and goto-cleanup in xqc_test_packet_encrypt_hp_sample_boundary, mirroring the defensive pattern already used by xqc_test_empty_pkt - Move 0-RTT test registration before hp_sample_boundary in main.c so they execute regardless of TLS cert availability Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
xqc_conn_tls_transport_params_cb()time.xqc_conn_validate_0rtt_transport_params()so unit tests can directly cover the remembered-value comparison without mock TLS/CID/encode-decode setup.max_datagram_frame_size0-RTT remembered-value check outside the TLS early-data guard. This preserves the existing case-test behavior where reducing or disabling DATAGRAM support must raiseTRA_0RTT_TRANS_PARAMS_ERRORand clear the saved 0-RTT ticket.xqc_test_packet_encrypt_hp_sample_boundaryto guard NULL engine/connection pointers so missing local TLS cert files fail the test instead of crashing the CUnit process.hp_sample_boundaryso their coverage is not hidden by unrelated cert-path failures.Root cause
0-RTT validation guard
For the RFC 9000 core transport parameters, the production callback should only validate remembered values when the client attempted 0-RTT and TLS reports early data accepted. The earlier
|| XQC_CONN_FLAG_0RTT_OKworkaround was ineffective in production because0RTT_OKis set after the transport-parameters callback.The unit-test problem was that mock connections created by
test_engine_connect()do not carry real resumption/early-data TLS state, so the callback guard was unreachable in those tests. Directly testing the extracted validator keeps the unit coverage focused on the comparison logic.DATAGRAM remembered parameter
max_datagram_frame_sizefollows RFC 9221 Section 3. If the client remembers this transport parameter for 0-RTT, the value received in the new handshake must not be smaller than the remembered value. That check must remain effective for the existing DATAGRAM case tests, including the path where the server disables DATAGRAM after a ticket was generated with DATAGRAM enabled.hp_sample_boundary SIGSEGV
xqc_test_packet_encrypt_hp_sample_boundaryuses test helpers that load./server.keyand./server.crt. When those files are absent from the current working directory, engine creation can fail. The test now checks those pointers before dereferencing them, so the suite reports a failed assertion instead of crashing.Test plan
make -C build -j4on local macOS worktreecd build && ./tests/run_tests: 127 tests passed, 0 failedBuild on Ubuntufor the latest PR head commit: run #875 passedReferences