MCPcopy Create free account
hub / github.com/apache/brpc / ParseEspMessage

Function ParseEspMessage

src/brpc/policy/esp_protocol.cpp:40–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38namespace policy {
39
40ParseResult ParseEspMessage(
41 butil::IOBuf* source,
42 Socket*,
43 bool /*read_eof*/,
44 const void* /*arg*/) {
45
46 EspHead head;
47 const size_t n = source->copy_to((char *)&head, sizeof(head));
48 if (n < sizeof(head)) {
49 return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA);
50 }
51
52 uint32_t body_len = head.body_len;
53 if (body_len > FLAGS_max_body_size) {
54 return MakeParseError(PARSE_ERROR_TOO_BIG_DATA);
55 } else if (source->length() < sizeof(head) + body_len) {
56 return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA);
57 }
58
59 policy::MostCommonMessage* msg = policy::MostCommonMessage::Get();
60 source->cutn(&msg->meta, sizeof(head));
61 source->cutn(&msg->payload, body_len);
62 return MakeMessage(msg);
63}
64
65void SerializeEspRequest(
66 butil::IOBuf* request_buf,

Callers 2

TEST_FFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85

Calls 6

MakeParseErrorFunction · 0.85
GetFunction · 0.85
MakeMessageFunction · 0.85
copy_toMethod · 0.45
lengthMethod · 0.45
cutnMethod · 0.45

Tested by 1

TEST_FFunction · 0.68