fix(http): respect header byte length when stringifying responses - #84
Conversation
76f95a3 to
3c78ef6
Compare
Exact-head follow-upChecked updated head The Makefile, HTTP serializer and new stringify test blobs are unchanged. The tree delta consists only of the JWT/WebTransport test fixes from the updated parent. This preserves the scope of the reviewed serializer change; it is not a claim that every new-head check has passed. New-head ASan/UBSan, h2spec baseline-diff and CodeQL have passed. The report-rendering job actually fails at its raw-allocator baseline substep, not rendering tests: four unchanged app.c allocation/free lines are recorded three lines earlier in the baseline (3854/3864/3986/3991 vs actual 3857/3867/3989/3994). Job: https://github.com/c4punks/CWIST/actions/runs/34761336803/job/103734594906 . Other jobs remain pending at this check; no all-green or merge claim. The separate safe-cache design is now proposed in #85. It does not activate caching or claim to resolve #25. |
3c78ef6 to
b344950
Compare
|
The head changed concurrently to
This is not all-green CI or P99.999 performance evidence. No branch overwrite or PR merge was performed. |
Summary
Related to #25. This is a small correctness prerequisite found while investigating FIXED-cache population, not a P99.999 performance fix or a cache-enablement change.
serialize_headersreturns a byte count. Neither its memcpy fast path nor its general path promises a trailing NUL.cwist_http_stringify_responsediscarded that count and passed the stack buffer to the strlen-based string assignment. That can copy unwritten stack bytes or read past the array.Use the returned length with
cwist_sstring_assign_len, and return NULL if the string object cannot be created. Body handling and managed-body lifetime remain unchanged. No header-buffer terminator write is needed, including when the returned span fills the buffer.Regression
Add
test_http_stringifyto the normal Makefile test list. Six wire cases plus NULL input cover empty/binary bodies, ordinary/managed pointer bodies, keep-alive/close, and custom headers. The test checks exact byte extent, payload bytes, framing and managed cleanup timing without assert-dependent setup. Default headers have an independent expected-byte oracle.On unchanged dev
7e19b461c5772f4e46e7d58fb96827bbb954cf97, the normal Linux build runs the regression and fails atwire->size == header_len + body_len. The candidate passes the same regression and its NDEBUG build. The original uninitialized-read failure is stack-layout dependent; no claim is made that every original build fails identically.Validation
test_middleware_jwtfails on array comparison andtest_webtransporton an unused parameter; both compiler failures were reproduced on the unchanged base during the preceding investigation.tests/lsan.suppused). Source identities in the isolated build trees match the reviewed candidate.Scope limits
This does not restore FIXED caching, change cache eligibility, bypass middleware, or change thread/backend defaults. It does not address the serializer's existing oversized-header behavior, invalid body-mode combinations, or all assignment/append allocation-failure handling. No measured tail-latency improvement is claimed.