You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "JosiahWI (via GitHub)" <gi...@apache.org> on 2026/06/05 12:22:48 UTC
[PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
JosiahWI opened a new pull request, #13242:
URL: https://github.com/apache/trafficserver/pull/13242
The length of the source buffer for HTTP3 type parsing was always taken
to be the maximum length of the type field. This seemed to work without
UB when I tested it through `Http3FrameDispatcher`, but Kit Chan pointed
out that it is risky (https://github.com/apache/trafficserver/issues/11720).
This patch refactors the type parsing to guarantee that the number of
bytes passed to the parser will not be greater than the number of
initialized bytes in the buffer.
Fixes #11720
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "zwoop (via GitHub)" <gi...@apache.org>.
zwoop commented on PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242#issuecomment-4632976830
[approve ci].
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242#discussion_r3362699571
##########
src/proxy/http3/Http3Frame.cc:
##########
@@ -534,9 +537,10 @@ Http3FrameFactory::create(IOBufferReader &reader)
std::shared_ptr<Http3Frame>
Http3FrameFactory::fast_create(IOBufferReader &reader)
{
- uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
- reader.memcpy(type_buf, sizeof(type_buf));
- Http3FrameType type = Http3Frame::type(type_buf, sizeof(type_buf));
+ uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
+ std::size_t const type_avail{std::min<std::size_t>(reader.read_avail(), sizeof(type_buf))};
+ reader.memcpy(type_buf, type_avail);
+ Http3FrameType type = Http3Frame::type(type_buf, type_avail);
Review Comment:
`type_buf_len` is not defined here; this looks like a typo and will fail to compile. It should use the clamped length you computed (`type_avail`) so `memcpy()` doesn't request more bytes than available.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "zwoop (via GitHub)" <gi...@apache.org>.
zwoop commented on PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242#issuecomment-4633043847
[approve ci]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI merged PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "maskit (via GitHub)" <gi...@apache.org>.
maskit commented on PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242#issuecomment-4636397443
I'm not sure if it's worth back porting this fix for 10.x. I'd leave it on master for 11.0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Clamp HTTP3 frame type buf size to reader bytes [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13242:
URL: https://github.com/apache/trafficserver/pull/13242#discussion_r3362601650
##########
src/proxy/http3/Http3Frame.cc:
##########
@@ -505,9 +507,10 @@ Http3FrameFactory::create(IOBufferReader &reader)
ts::Http3Config::scoped_config params;
Http3Frame *frame = nullptr;
- uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
- reader.memcpy(type_buf, sizeof(type_buf));
- Http3FrameType type = Http3Frame::type(type_buf, sizeof(type_buf));
+ uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
+ std::size_t const type_avail{std::min<std::size_t>(reader.read_avail(), sizeof(type_buf))};
+ reader.memcpy(type_buf, type_buf_len);
+ Http3FrameType type = Http3Frame::type(type_buf, type_avail);
Review Comment:
`reader.memcpy(type_buf, type_buf_len);` uses an undefined identifier and won’t compile. It also defeats the intent of clamping the copy length to the available bytes; this should copy `type_avail` bytes.
##########
src/proxy/http3/Http3Frame.cc:
##########
@@ -534,9 +537,10 @@ Http3FrameFactory::create(IOBufferReader &reader)
std::shared_ptr<Http3Frame>
Http3FrameFactory::fast_create(IOBufferReader &reader)
{
- uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
- reader.memcpy(type_buf, sizeof(type_buf));
- Http3FrameType type = Http3Frame::type(type_buf, sizeof(type_buf));
+ uint8_t type_buf[FRAME_TYPE_MAX_BYTES]{};
+ std::size_t const type_avail{std::min<std::size_t>(reader.read_avail(), sizeof(type_buf))};
+ reader.memcpy(type_buf, type_buf_len);
+ Http3FrameType type = Http3Frame::type(type_buf, type_avail);
Review Comment:
`reader.memcpy(type_buf, type_buf_len);` uses an undefined identifier and will fail to compile. To keep the copy bounded to initialized bytes (the goal of this PR), it should copy `type_avail` bytes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org