Skip to content

http: hand back response body without copying it#3

Merged
HarryR merged 1 commit into
mainfrom
fix-http-body-copy
Jul 5, 2026
Merged

http: hand back response body without copying it#3
HarryR merged 1 commit into
mainfrom
fix-http-body-copy

Conversation

@HarryR

@HarryR HarryR commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

From the stage0 boot-path security review (buffer-duplication pass).

http::request extracted the response body with raw[sep + 4..].to_vec(), copying the whole tail into a fresh Vec and then dropping raw. On the payload download that is a full-length memcpy and roughly 2x peak memory for the transfer. This switches to raw.split_off(sep + 4), which reuses the existing allocation and hands back the tail directly.

No behavior change: the returned bytes are identical, so admission (sha256 / ed25519) and PCR 14 measurement are unaffected.

Verified: make boot-x86_64 boots the full chain (payload downloaded, admitted, measured, chain-loaded) and fails closed as expected.

🤖 Generated with Claude Code

Extract the HTTP body by reusing the response buffer's allocation
(split_off) instead of copying the whole tail into a fresh Vec. On the
payload download this drops a full-length memcpy and roughly halves peak
memory for the transfer. The returned bytes are identical, so admission
and measurement are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@HarryR HarryR merged commit e6d70ac into main Jul 5, 2026
3 checks passed
@HarryR HarryR deleted the fix-http-body-copy branch July 5, 2026 16: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.

1 participant