Skip to content

Commit

Permalink
Fix stack buffer overflow issue when calling copy_to_cstr (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenrryyou authored May 18, 2023
1 parent bfb26a1 commit d3de081
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/brpc/input_messenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ ParseResult InputMessenger::CutInputMessage(
return result;
} else {
if (m->_read_buf.size() >= 4) {
char data[PROTO_DUMMY_LEN];
// The length of `data' must be PROTO_DUMMY_LEN + 1 to store extra ending char '\0'
char data[PROTO_DUMMY_LEN + 1];
m->_read_buf.copy_to_cstr(data, PROTO_DUMMY_LEN);
if (strncmp(data, "RDMA", PROTO_DUMMY_LEN) == 0 &&
m->_rdma_state == Socket::RDMA_OFF) {
Expand Down

0 comments on commit d3de081

Please sign in to comment.