You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2020/02/28 03:32:36 UTC
[rocketmq-client-cpp] branch master updated: fix(memory):
heap-buffer-overflow due to wrong use of strcpy.
This is an automated email from the ASF dual-hosted git repository.
dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new e51b7b0 fix(memory): heap-buffer-overflow due to wrong use of strcpy.
e51b7b0 is described below
commit e51b7b0cd4987e768d7edd3673746da37117b78a
Author: yizhe.wcm <42...@users.noreply.github.com>
AuthorDate: Fri Feb 28 11:32:15 2020 +0800
fix(memory): heap-buffer-overflow due to wrong use of strcpy.
---
test/src/common/big_endianTest.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/src/common/big_endianTest.cpp b/test/src/common/big_endianTest.cpp
index 5469ded..06432d2 100644
--- a/test/src/common/big_endianTest.cpp
+++ b/test/src/common/big_endianTest.cpp
@@ -62,7 +62,7 @@ TEST(big_endian, bigEndianObject) {
char* newBuf = (char*)malloc(sizeof(char) * 8);
char* writeBuf = (char*)malloc(sizeof(char) * 8);
- strcpy(writeBuf, "RocketMQ");
+ strncpy(writeBuf, "RocketMQ", 8);
EXPECT_TRUE(writer.WriteBytes(writeBuf, (size_t)8));
EXPECT_TRUE(reader.ReadBytes(newBuf, (size_t)8));
EXPECT_EQ(*writeBuf, *newBuf);
@@ -76,7 +76,7 @@ TEST(big_endian, bigEndian) {
/*TODO
char *newBuf = (char *) malloc(sizeof(char) * 8);
- strcpy(newBuf, "RocketMQ");
+ strncpy(newBuf, "RocketMQ", 8);
char readBuf[8];
rocketmq::WriteBigEndian(writeBuf, newBuf);