This is an automated email from the ASF dual-hosted git repository.
bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 5f7981e Fix buffer overflow gripes in RHEL-8 build (#861)
5f7981e is described below
commit 5f7981e1ca7c980e699ade47dfbe927b98f8d025
Author: Blake Bender <[email protected]>
AuthorDate: Thu Aug 26 13:20:33 2021 -0700
Fix buffer overflow gripes in RHEL-8 build (#861)
- RHEL-8 CI images appear to have picked up a new compiler that's
flagging some broken sprintf code in a couple of legacy tests.
---
cppcache/integration-test/testExpiration.cpp | 25 ++++++++--------------
.../testThinClientLRUExpiration.cpp | 10 +++------
2 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/cppcache/integration-test/testExpiration.cpp
b/cppcache/integration-test/testExpiration.cpp
index a3678be..08b374c 100644
--- a/cppcache/integration-test/testExpiration.cpp
+++ b/cppcache/integration-test/testExpiration.cpp
@@ -54,33 +54,26 @@ void startDSandCreateCache(std::shared_ptr<Cache> &cache) {
void doNPuts(std::shared_ptr<Region> &rptr, int n) {
std::shared_ptr<CacheableString> value;
- char buf[16];
- memset(buf, 'A', 15);
- buf[15] = '\0';
- memcpy(buf, "Value - ", 8);
- value = CacheableString::create(buf);
+ value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");
for (int i = 0; i < n; i++) {
- sprintf(buf, "KeyA - %d", i + 1);
- auto key = CacheableKey::create(buf);
- LOGINFO("Putting key %s value %s in region %s", buf,
+ auto keyStr = std::string("KeyA - ") + std::to_string(i + 1);
+ auto key = CacheableKey::create(keyStr);
+ LOGINFO("Putting key %s value %s in region %s", keyStr.c_str(),
value->toString().c_str(), rptr->getFullPath().c_str());
rptr->put(key, value);
}
}
+
std::shared_ptr<CacheableKey> do1Put(std::shared_ptr<Region> &rptr) {
std::shared_ptr<CacheableString> value;
- char buf[16];
- memset(buf, 'A', 15);
- buf[15] = '\0';
- memcpy(buf, "Value - ", 8);
- value = CacheableString::create(buf);
+ value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");
- sprintf(buf, "KeyA - %d", 0 + 1);
- auto key = CacheableKey::create(buf);
- LOGINFO("Putting key %s value %s in region %s", buf,
+ std::string keyStr("KeyA - 1");
+ auto key = CacheableKey::create(keyStr);
+ LOGINFO("Putting key %s value %s in region %s", keyStr.c_str(),
value->toString().c_str(), rptr->getFullPath().c_str());
rptr->put(key, value);
return key;
diff --git a/cppcache/integration-test/testThinClientLRUExpiration.cpp
b/cppcache/integration-test/testThinClientLRUExpiration.cpp
index 1adb0f0..8ddf7c2 100644
--- a/cppcache/integration-test/testThinClientLRUExpiration.cpp
+++ b/cppcache/integration-test/testThinClientLRUExpiration.cpp
@@ -172,19 +172,15 @@ void createRegion(const char *name, bool ackMode,
void doRgnOperations(const char *name, int n, int rgnOpt = 0) {
std::shared_ptr<CacheableString> value;
- char buf[16];
if (rgnOpt == 0) {
- memset(buf, 'A', 15);
- buf[15] = '\0';
- memcpy(buf, "Value - ", 8);
- value = CacheableString::create(buf);
+ value = CacheableString::create("Value - AAAAAAA");
ASSERT(value != nullptr, "Failed to create value.");
}
auto rptr = getHelper()->getRegion(name);
ASSERT(rptr != nullptr, "Region not found.");
for (int i = 0; i < n; i++) {
- sprintf(buf, "KeyA - %d", i + 1);
- auto key = CacheableKey::create(buf);
+ auto keyStr = std::string("KeyA - ") + std::to_string(i + 1);
+ auto key = CacheableKey::create(keyStr);
switch (rgnOpt) {
case 0:
rptr->put(key, value);