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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]