Skip to content

Fix oversized reads in EncapsulatedSession::InnerStream::Read. - #157

Open
neeraj1235476 wants to merge 1 commit into
google:mainfrom
neeraj1235476:encapsulated-wt-partial-read
Open

neeraj1235476 wants to merge 1 commit into
google:mainfrom
neeraj1235476:encapsulated-wt-partial-read

Conversation

@neeraj1235476

Copy link
Copy Markdown

EncapsulatedSession::InnerStream::Read(absl::Span<char>) reports output.size() as bytes_read even when the stream has fewer bytes buffered, and then skips that many bytes:

encapsulated_web_transport.cc:589] WT_H2_SkipBytes_toomuch: Requested to skip 12 bytes that are not present in the read buffer.

The webtransport::Stream contract allows reading into a buffer larger than ReadableBytes() (the QUIC-backed WebTransportStreamAdapter handles that case correctly), so a caller using a fixed-size buffer gets back a bytes_read larger than what was written and processes the uninitialized tail of its buffer as data received from the peer. The FIN is also lost in that case, since SkipBytes() bails out on the bug check before consuming it.

Count the bytes actually copied and skip only those. The new ReadIntoOversizedBuffer test covers both the bytes_read value and FIN delivery; it fails before this change and passes after.

This fix was found and prepared with AI assistance and reviewed by me before submitting.

Read() reported output.size() as bytes_read even when fewer bytes were
buffered on the stream, so a caller reading into a fixed-size buffer
would treat the uninitialized tail of its buffer as data received from
the peer. The over-sized SkipBytes() call also hit QUICHE_BUG
WT_H2_SkipBytes_toomuch and dropped the FIN signal. Count the bytes
actually copied, skip only those, and return that count.
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@google-cla

google-cla Bot commented Oct 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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