Skip to content

Conversation

@Sy0307
Copy link
Collaborator

@Sy0307 Sy0307 commented Nov 24, 2025

Related issue: #518 #511

Issue: xqc_hq_parse_req uses sscanf("%s %s") without bounds, so a long URL from neqo overruns the 256‑byte buffer. Since xqc_hq_request_recv_req didn’t null‑terminate the buffer, later strlen() walks into uninitialized memory, causing an ASan heap-buffer-overflow and leaving HQ requests stuck after “hq recv CR LF”.
Fixes:
Build a bounded format string (e.g. "%15s %255s") before calling sscanf, so both method and path respect the buffer size.
After reading from the QUIC stream, check whether recv_cnt hits the buffer limit; if not, append '\0'. This guarantees strlen()/sscanf() operate on a valid C string.

When neqo client interop with xquic server, xquic server will trigger core dump & timeout, gdb log like this:

=================================================================
==8799==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x615000002080 …
    #3 0x100f51c80 in xqc_hq_parse_req xqc_hq_request.c:234
    #4 0x100f52aac in xqc_hq_request_recv_req xqc_hq_request.c:297
    #5 0x100f58600 in xqc_demo_svr_hq_req_read_notify demo_server.c:632
    

This PR will solve the issue of parsing error if server run as expected.

@Sy0307 Sy0307 requested a review from Yanmei-Liu November 24, 2025 09:02
Copy link
Collaborator

@Yanmei-Liu Yanmei-Liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solve interop test error. Looks good.

@Yanmei-Liu Yanmei-Liu merged commit 108a34c into main Nov 25, 2025
6 checks passed
@Yanmei-Liu Yanmei-Liu deleted the fix/hq_interop_error branch November 25, 2025 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants