Skip to content

Commit

Permalink
Merge pull request #6 from benyucong/cp_internal
Browse files Browse the repository at this point in the history
fix: Fix stack buffer overflow issue when calling copy_to_cstr
  • Loading branch information
hustnn authored Jul 21, 2023
2 parents c83d7d7 + e95c05f commit 53eb5c0
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 @@ -94,7 +94,8 @@ ParseResult InputMessenger::CutInputMessage(
return result;
} else {
if (m->_read_buf.size() >= 4) {
char data[PROTO_DUMMY_LEN];
// `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 53eb5c0

Please sign in to comment.