Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/proxy/http3/Http3Frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "proxy/http3/Http3Frame.h"
#include "proxy/http3/Http3Config.h"

#include <algorithm>

ClassAllocator<Http3Frame, false> http3FrameAllocator("http3FrameAllocator");
ClassAllocator<Http3DataFrame, false> http3DataFrameAllocator("http3DataFrameAllocator");
ClassAllocator<Http3HeadersFrame, false> http3HeadersFrameAllocator("http3HeadersFrameAllocator");
Expand Down Expand Up @@ -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_avail);
Http3FrameType type = Http3Frame::type(type_buf, type_avail);
Comment thread
JosiahWI marked this conversation as resolved.

switch (type) {
case Http3FrameType::HEADERS:
Expand All @@ -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);
Comment thread
JosiahWI marked this conversation as resolved.
Comment thread
JosiahWI marked this conversation as resolved.
if (type == Http3FrameType::UNKNOWN) {
if (!this->_unknown_frame) {
this->_unknown_frame = Http3FrameFactory::create(reader);
Expand Down