This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new d3de0817 Fix stack buffer overflow issue when calling copy_to_cstr
(#2253)
d3de0817 is described below
commit d3de08179e94241f05425a1fdb3f66b989ca436a
Author: Jenrry You <[email protected]>
AuthorDate: Thu May 18 10:05:31 2023 +0800
Fix stack buffer overflow issue when calling copy_to_cstr (#2253)
---
src/brpc/input_messenger.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/brpc/input_messenger.cpp b/src/brpc/input_messenger.cpp
index 699f080c..1234eef4 100644
--- a/src/brpc/input_messenger.cpp
+++ b/src/brpc/input_messenger.cpp
@@ -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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]